Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to output audio on Arch Linux #1

Closed
J-tt opened this issue Jun 11, 2017 · 25 comments
Closed

Unable to output audio on Arch Linux #1

J-tt opened this issue Jun 11, 2017 · 25 comments

Comments

@J-tt
Copy link
Contributor

J-tt commented Jun 11, 2017

Running Arch Linux (64bit). Python 3.6.1 is installed.

ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pulse.c:243:(pulse_connect) PulseAudio: Unable to connect: Connection refused

ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm_dsnoop.c:638:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1099:(snd_pcm_dmix_open) unable to open slave
connect(2) call to /dev/shm/jack-0/default/jack_0 failed (err=No such file or directory)
attempt to connect to server failed
Default Audio Player for mp3 files is not set up, like vlc or something.

ALSA Is installed (info)

@JoshkVFX
Copy link

What was the command you ran to get to this return?
Also do you have a Default Audio Player set for mp3 files?

@ghost
Copy link

ghost commented Jun 11, 2017

I don't think ALSA is your problem. In the directory stephanie-va-master/Stephanie/TextManager, there's a file called speaker.py. In there on line 15, it says os.startfile(self.speak_result). The problem with that is os.startfile is windows only. I replaced that line with os.system("xdg-open " + self.speak_result) and everything started working.

@JoshkVFX
Copy link

@highmindedlowlife Is there an os independant option?

@J-tt J-tt changed the title Not connecting to ALSA Unable to output audio on Arch Linux Jun 11, 2017
@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

@highmindedlowlife

I tried this, still getting the same errors on startup. This seems to be very broken on Arch.

I'll try using KDE Plasma instead of i3, as I think it is trying to get some OS variables that don't exist in i3.

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

There is pygame, which can be set in config.ini file under [TTS] tts_player = pygame, but it is quite buggy, and I am afraid but I don't have a linux based system with me right now, if anyone could send me pull request that can accommodate linux systems, then that'd be really helpful.

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

It's pretty easy to spin up a Linux VM. I don't have a huge amount of experience with python, but I'll do some digging.

@JoshkVFX
Copy link

There is a pretty easy way but it's basically just a function with an if statement inside. Should I make a pull request?

@ghost
Copy link

ghost commented Jun 11, 2017

@JoshKellyVFX

is there an OS independent option?

I'm not sure that there is but both could be wrapped in try catch blocks so that if os.startfile fails, it can try os.system("xdg-open"). It could also just use sys.platform to see what it's running on and use the right one that way. Unfortunately I'm an amateur pythonista so who knows.
Maybe something like:

if sys.platform == "linux":
    os.system("xdg-open " + self.speak_result)
else:
    os.startfile(self.speak_result)

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

@JoshKellyVFX

There is a pretty easy way but it's basically just a function with an if statement inside. Should I make a pull request?

Yes please, put up try and catch block as well!

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

Can anyone try os.system(self.speak_result) and let me know if it still works, because system command seems to be cross platform since it's working identical to startfile command.

@JoshkVFX
Copy link

Works on linux

@ghost
Copy link

ghost commented Jun 11, 2017

@SlapBot

Can anyone try os.system(self.speak_result)

Just tried it and it doesn't work. os.system needs a specific command to run so in this case, it needs the name of the media player you want to use, e.g., os.system("mplayer " + self.speak_result) or os.system("xdg-open " + self.speak_result). It's subtly different from os.startfile which doesn't need the name of the application itself, just the mp3 to be played.

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

As @highmindedlowlife mentioned, I think this is the best solution, it's working for me.

/Stephanie/TextManager/speaker.py:15

if sys.platform == "win32":
    os.startfile(self.speak_result)
else:
    os.system("xdg-open " + self.speak_result)

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

Hmm, so what's your thoughts on something like this:

    def speak_from_os(self, speech_result_filename):
        self.speak_result = self.get_abs_filename(speech_result_filename)
        try:
            if sys.platform == "linux":
                try:
                    os.system(self.speak_result)
                except Exception as e2:
                    try:
                        os.system("mplayer " + self.speak_result)
                    except Exception as e3:
                        try:
                            os.system("xdg-open " + self.speak_result)
                        except Exception as e4:
                            raise e4
            else:
                try:
                    os.startfile(self.speak_result)
                except Exception as e1:
                    raise e1     
        except:
            print("Default Audio Player for mp3 files is not set up, like vlc or something.")
        try:
            self.hibernate()
        except:
            print("Something went wrong with your stupid system, eyed3 named package wasn't installed probably "
                  "Check back at the support tab in the main website. Don't worry mate, I'll help you. Or if you're "
                  "trying to close the application abruptly, keep pressing CTRL + C repeatedly.")

@JoshkVFX
Copy link

@SlapBot it seems a bit over the top, the fix @highmindedlowlife mentioned is probably best

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

Also @SlapBot, any particular reason for the aggressive error messages?

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

@J-tt

any particular reason for the aggressive error messages?

Sorry for that will fix this, but the above commit doesn't take win64 as well as any other irregularities, I think nested try approach can be better? I can remove sys.platform command as well for one more level of try statement. I am not too sure about it though.

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

@SlapBot
It checks for any version of windows (see this).

This will work fine as a temp fix, and at least let Linux users run the program.

@JoshkVFX
Copy link

JoshkVFX commented Jun 11, 2017

@SlapBot Try statements bring iffy code, we can add a x86-64 check in the if statement

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

@JoshKellyVFX We don't need a check, as if the system is running windows it will return win32 to sys.platform, I have a 64bit version of python, and I got win32.

@JoshkVFX
Copy link

@J-tt I thought so, I just couldn't remember if that was the case. So the pull request is good

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

@JoshKellyVFX
Yep, I linked this SO answer in my previous comment:

https://stackoverflow.com/questions/2144748/is-it-safe-to-use-sys-platform-win32-check-on-64-bit-python#2145582

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

For now temporarily, I have resorted to @J-tt commit.
temp fix

@SlapBot
Copy link
Owner

SlapBot commented Jun 11, 2017

@J-tt Oh crap instead of merging I did it myself, sorry man, I am still kind of new with github!

@J-tt
Copy link
Contributor Author

J-tt commented Jun 11, 2017

All good, just hit merge on the pull :)

SlapBot added a commit that referenced this issue Jun 11, 2017
Fix #1, non OS dependant audio output
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants