ImJhardy
ImJhardy

Reputation: 1

How to setup microphone with Azure Speech Services C# SDK on Raspberry Pi 4

I am playing around creating a home assistant using Raspberry Pi 4 and Azure speech services. I have a keyword model setup and listen for the keyword using the following code.

using AudioConfig audioConfig = AudioConfig.FromDefaultMicrophoneInput();
using var keywordRecognizer = new KeywordRecognizer(audioConfig);
await keywordRecognizer.RecognizeOnceAsync(keyword);

This works flawlessly when running on my windows 10 laptop (using the laptop microphone) inside VS 2022.

The microphone I am using with the raspberry pi is the Respeaker 4-mic array.

When I deploy it to the raspberry pi it doesn't seem to pick up the microphone. I have edited etc/asound.conf to ensure the microphone I want to use is set as the default. My microphone uses card 1 and is device 0. I have tested that the microphone does work use Audacity.

I have even swapped the .FromDefaultMicrophoneInput to:

using AudioConfig audioConfig = AudioConfig.FromMicrophoneInput("hw:CARD=1,DEV=0");

or

using AudioConfig audioConfig = AudioConfig.FromMicrophoneInput("hw:1,0");

following azures documentation: https://learn.microsoft.com/en-gb/azure/cognitive-services/speech-service/how-to-select-audio-input-devices

The two above crash with the error: SPXERR_MIC_NOT_AVAILABLE. This makes me believe that the microphone isn't being found.

Any help on how I can get the Azure SDK to use the microphone on the Raspberry Pi for Keyword recognition would be greatly appriciated.

Many thanks

EDIT: I have tried a USB microphone and this does work. It seems to an issue around using a microphone connected via the GPIO pins?

Upvotes: 0

Views: 595

Answers (1)

Installation of the ALSA libraries help to solve the SPXERR_MIC_NOT_AVAILABLE issue on my RPi 3.

sudo apt-get install gcc libasound2 libasound2-dev alsa-utils

Upvotes: 0

Related Questions