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

Issues connecting to microphone using systemd #1594

Closed
michaelshorter opened this issue Jul 27, 2022 · 4 comments
Closed

Issues connecting to microphone using systemd #1594

michaelshorter opened this issue Jul 27, 2022 · 4 comments

Comments

@michaelshorter
Copy link

michaelshorter commented Jul 27, 2022

Hello,

I have created a script using speech to text that when run in terminal works perfectly, but when run during startup using systemd gives me an error that I think means it's not finding the microphone.

Here is the error it throws up:

JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
ALSA lib pcm_oss.c:397:(_snd_pcm_oss_open) Cannot open device /dev/dsp
ALSA lib pulse.c:242:(pulse_connect) PulseAudio: Unable to connect: Connection refused
Unhandled exception. System.ApplicationException: Exception with an error code: 0xe (SPXERR_MIC_NOT_AVAILABLE)
at Microsoft.CognitiveServices.Speech.Internal.SpxExceptionThrower.ThrowIfFail(IntPtr hr)
at Microsoft.CognitiveServices.Speech.Recognizer.FromConfig(GetRecognizerFromConfigDelegate fromConfig, SpeechConfig speechConfig, AudioConfig audioConfig)
at Microsoft.CognitiveServices.Speech.SpeechRecognizer..ctor(SpeechConfig speechConfig, AudioConfig audioConfig)
at Program.Main(String[] args) in /home/wordcloud/WordCloud/AzureSpeechCC/Program.cs:line 35
at Program.

(String[] args)

You can find my code here if that's useful - https://github.com/michaelshorter/WordCloud

I've also tried auto starting my script using cron and rc.local but still no joy. I presume the same issue is happening here but I'm not able to debug it so easily.

Has anyone had this issue before? If so I'd massively appreciate some pointers on how to fix it!

Cheers,
M

@michaelshorter michaelshorter changed the title Issues coonecting to microphone using systemd Issues connecting to microphone using systemd Jul 27, 2022
@brandom-msft
Copy link
Contributor

Hi @michaelshorter
What are you running this on? Capturing a log might give us more information
https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/how-to-use-logging

The error does look to indicate a failure to get microphone access. Since you mentioned this fails when trying to run at startup, I'm wondering if your hardware is active and/or if any sort of microphone access needs to be granted.

@glecaros
Copy link
Contributor

Hi @michaelshorter, was your issue resolved, or were you able to capture logs as @brandom-msft suggested?

@michaelshorter
Copy link
Author

michaelshorter commented Aug 25, 2022

Hi @brandom-msft @glecaros
It was an issue accessing the right port for the microphone. The problem was fixed by specifying the default sound card that I wanted to use. Still no idea why this was only an issue when running the file with a service file.... Here is a link to the forum post that saved the day:

https://askubuntu.com/questions/150851/how-do-i-select-a-default-sound-card-with-alsa

@glecaros
Copy link
Contributor

great! glad to you were able to solve it, I'll go ahead and close the issue then

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