MycroftAI / mycroft-core

Mycroft Core, the Mycroft Artificial Intelligence platform.
https://mycroft.ai
Apache License 2.0
6.51k stars 1.27k forks source link

Mycroft should work with pipewire on Linux #2980

Open mekwall opened 3 years ago

mekwall commented 3 years ago

Is your feature request related to a problem? Please describe. I am unable to install Mycroft because I am using pipewire instead of pulseaudio. Since pipewire is compatible with pulseaudio Mycroft shouldn't need to explicitly install pulseaudio if pipewire-pulseaudio is already installed (they are conflicting).

Describe the solution you'd like Add support for pipewire-pulseaudio.

Describe alternatives you've considered The alternative is to reinstall pulseaudio which I am not willing to do since pipewire is needed for other applications on my system.

mekwall commented 3 years ago

I removed pulseaudio from dev_setup.sh and I could install Mycroft and it works out-of-the-box with pipewire. Note that I'm on Archlinux, but should work fine with other distros as well. The solution is to add logic to dev_setup.sh that checks if pipewire-pulseaudio is already installed before trying to install pulseaudio. That should solve any conflicts.

krisgesling commented 3 years ago

Hey, thanks for flagging that, if anyone has a modification to the dev_setup.sh script they'd like to share back, PR's are most welcome :)

CodeCanna commented 3 years ago

I removed pulseaudio from dev_setup.sh and I could install Mycroft and it works out-of-the-box with pipewire. Note that I'm on Archlinux, but should work fine with other distros as well. The solution is to add logic to dev_setup.sh that checks if pipewire-pulseaudio is already installed before trying to install pulseaudio. That should solve any conflicts.

I wrote a function that checks for the presence of pulse audio by checking for the directory /etc/pulse but should I be checking for something more specific having to do with pipewire?

# Check for versions of pulse audio accross multiple distros
function installed_pulseAudio() {
    # Check for PulseAudio
    if [ ! -d "/etc/pulse" ]; then
        return 1;
    fi

    return 0;
}

Then I use it to check for pulse audio before installing the packages:

function debian_install() {
    if installed_pulseAudio; then
        APT_PACKAGE_LIST="git python3 python3-dev python3-setuptools libtool \
        libffi-dev libssl-dev autoconf automake bison swig libglib2.0-dev \
        portaudio19-dev mpg123 screen flac curl libicu-dev pkg-config \
        libjpeg-dev libfann-dev build-essential jq"
    else
        APT_PACKAGE_LIST="git python3 python3-dev python3-setuptools libtool \
            libffi-dev libssl-dev autoconf automake bison swig libglib2.0-dev \
            portaudio19-dev mpg123 screen flac curl libicu-dev pkg-config \
            libjpeg-dev libfann-dev build-essential jq pulseaudio \
            pulseaudio-utils"
    fi
    if dpkg -V libjack-jackd2-0 > /dev/null 2>&1 && [[ -z ${CI} ]] ; then
        echo "
We have detected that your computer has the libjack-jackd2-0 package installed.
Mycroft requires a conflicting package, and will likely uninstall this package.
On some systems, this can cause other programs to be marked for removal.
Please review the following package changes carefully."
        read -p "Press enter to continue"
        $SUDO apt-get install $APT_PACKAGE_LIST
    else
        $SUDO apt-get install -y $APT_PACKAGE_LIST
    fi
}

Am I on the right track?

ChanceNCounter commented 3 years ago

imo, yes, but since dev_setup already works its way through each package manager, I think it might be better to ask the package manager if pulse is present, rather than checking the filesystem.

CodeCanna commented 3 years ago

imo, yes, but since dev_setup already works its way through each package manager, I think it might be better to ask the package manager if pulse is present, rather than checking the filesystem.

Yeees I was thinking of this as well. It would be more distro-specific then I would imagine. It might not always be /etc/pulse.

CodeCanna commented 3 years ago

Got it written for Debian/Ubuntu just have to write it for the rest of them:

function debian_install() {
    # Check that pulse audio isn't already installed
    if dpkg -V pulseaudio > /dev/null; then
        echo "It looks like pulse audio is already installed on your system, skipping pulse audio.";

        APT_PACKAGE_LIST="git python3 python3-dev python3-setuptools libtool \
        libffi-dev libssl-dev autoconf automake bison swig libglib2.0-dev \
        portaudio19-dev mpg123 screen flac curl libicu-dev pkg-config \
        libjpeg-dev libfann-dev build-essential jq"
    else
        APT_PACKAGE_LIST="git python3 python3-dev python3-setuptools libtool \
        libffi-dev libssl-dev autoconf automake bison swig libglib2.0-dev \
        portaudio19-dev mpg123 screen flac curl libicu-dev pkg-config \
        libjpeg-dev libfann-dev build-essential jq pulseaudio \
        pulseaudio-utils"
    fi

    if dpkg -V libjack-jackd2-0 > /dev/null 2>&1 && [[ -z ${CI} ]] ; then
        echo "
We have detected that your computer has the libjack-jackd2-0 package installed.
Mycroft requires a conflicting package, and will likely uninstall this package.
On some systems, this can cause other programs to be marked for removal.
Please review the following package changes carefully."
        read -p "Press enter to continue"
        $SUDO apt-get install $APT_PACKAGE_LIST
    else
        $SUDO apt-get install -y $APT_PACKAGE_LIST
    fi
}

Do we want to echo saying "hey pulse audio isn't installed" and vice versa? Or just do it quietly in the background?

CodeCanna commented 3 years ago

Also it looks like gentoo_install() and alpine_install() don't install pulse. I think I'm ready for review/pull request. I have never contributed to a project of this scale so please bear with me. :)

EDIT: Is this link helpful? https://github.com/CodeCanna/mycroft-core/commit/578453455f8bc5098ae7ecb90a26d2f5d737ab28

krisgesling commented 3 years ago

Hey @CodeCanna, thanks for taking on the challenge and contributing to open source :)

In terms of how to submit your code, take a look at our Contributing Guide as this contains a run through of how to fork the project, make your changes and submit them back as a Pull Request.

Regarding the fix itself, should we be looking for some pipewire package rather than pulseaudio or does pipewire install a pulseaudio package in order to emulate pulse?

CodeCanna commented 3 years ago

Hey @CodeCanna, thanks for taking on the challenge and contributing to open source :)

Thank you so much! This project in particular makes me very excited, especially how far it has come. I feel privileged to be able to work on such an important potentially game changing piece of software.

Regarding the fix itself, should we be looking for some pipewire package rather than pulseaudio or does pipewire install a pulseaudio package in order to emulate pulse?

I think what I'm missing is that pulseaudio and pulseaudio-pipewire are two different packages, I'm checking explicitly for pulseaudio at the moment. It does seem that pipewire might emulate pulse or something similar.

@mekwall's issue states:

Mycroft shouldn't need to explicitly install pulseaudio if pipewire-pulseaudio is already installed (they are conflicting).

So I think I should adjust my code to check for pipewire-pulseaudio before I submit my pull request, as well as read the Contribution Guide.

@mekwall so you have pipewire-pulse installed? And if pipwire-pulse is already installed; then don't install pulseaudio.

ChanceNCounter commented 3 years ago

@CodeCanna I suggest simplifying it by appending the appropriate package to the list of deps, rather than duplicating it, but that would require a little reworking.

CodeCanna commented 3 years ago

@CodeCanna I suggest simplifying it by appending the appropriate package to the list of deps, rather than duplicating it, but that would require a little reworking.

So something like (pseudo code):

if pipewire-pulse is.installed; then
    deplist = deplist.remove(pulseaudio) # Remove pulseaudio from the list of packages to be installed.
else
    deplist = deplist.add(pulseaudio) # Add pulseaudio to the list of packages to be installed.
fi
ChanceNCounter commented 3 years ago

Basically. Start with all the deps except pulse, and only add pulse if pipewire is absent. Otherwise add pipewire-pulse.

1Maxnet1 commented 2 years ago

Any news on this issue? Just ran into the exact same issue :)

krisgesling commented 2 years ago

Hey there, it's not something we're actively working on but happy to accept a pull request if anyone wants to propose a way forward for it.

khionu commented 2 years ago

PR opened. Imo, it would be better for dependencies to be separate from the rest of the script, as it's not great form to have package managers (venv and co aside) invocations hidden like this, but this WorksOnMyMachine:tm:. I have pipewire installed as well, so I can't test the other case.

krisgesling commented 2 years ago

Going to keep this issue open as it still exists on other distros.

PureTryOut commented 2 years ago

Note that on Alpine Linux this isn't a problem. Only pulseaudio-utils and pulseaudio-dev are being installed which both can exist fine alongside PipeWire-Pulse on the same system. Actually I tried the script just now without pulseaudio-dev installed (and I removed it from dev_setup.sh) and it still installs fine, so I wonder why it's even there in the first place.

In general however I would recommend against explicitly installing a sound system and just relying on the user having done so themselves. Then they can decide for themselves if they want PulseAudio or PipeWire, or even $insert-another-sound-system-here. MyCroft just needs to make sure it follows some basic standards to play any audio.

khionu commented 2 years ago

Seconding, as I think it should be considered by the maintainers whether to remove dependency installation on Linux. This would make it easier to package for every distro if dependencies are not installed automatically

PureTryOut commented 2 years ago

That's not necessary, distros have no need to run dev_setup.sh in the first place (the name of the script implies why) and the Alpine Linux packaging is an example of how.

LuNeder commented 1 year ago

Can confirm this issue still exists on OpenSUSE. Note that Zypper has great conflict resolution, so if you only didn´t choose cancel automatically when zypper asks how to fix the conflicts then the user could just select option 2 to skip pulse installation

ChanceNCounter commented 1 year ago

This repository is currently stale, as MycroftAI has ceased all development activities. A derivative FOSS org called OVOS (@OpenVoiceOS) is asserting itself on the community front, and Mycroft turned over retail support to the company behind an OVOS-based assistant, @NeonGeckoCom (NeonAI)

FAQ at the Mycroft forums: https://community.mycroft.ai/t/faq-ovos-neon-and-the-future-of-the-mycroft-voice-assistant/13496

JarbasAl commented 1 year ago

ovos-dinkum-listener can even run on MacOS nowadays, no dependency on any particular audio stack is in there, and if any shows up we have microphone-plugins to handle platform supports

theoretically ovos-dinkum-listener could even work in windows if microphone reading was the only issue

tldr, this issue doesnt exist anymore in the surviving mycroft projects, read FAQ above

LuNeder commented 1 year ago

Whaaaat Mycroft has ceased development?

(Maybe they should add this at their homescreen/download screen?)

el-tocino commented 1 year ago

They're down to a single employee juggling every aspect of things, so it's probably not a high priority for them at the moment.