speech_recognition icon indicating copy to clipboard operation
speech_recognition copied to clipboard

Using SpeechRecognition on a Raspberry Pi 400 doesn't work

Open Bradams2212 opened this issue 2 years ago • 1 comments

Steps to reproduce

As far as I'm aware, just trying to use the library on the raspberry pi causes issues. This was the code I used: import speech_recognition as sr def getMic(parent): r = sr.Recognizer() with sr.Microphone as source: audioData = r.listen(source) #Reads mic data until there is a significant pause try: words = parent.r.recognize_google(audioData) #Attempts to convert audio to a string except: return 'asdsafdfa' return words.lower()

Expected behaviour

I expected it to work fine and convert the audiodata to text. I have saved the audiodata as a wav and checked that it is fine.

Actual behaviour

An error occurs at 'words = parent.r.recognize_google(audioData)' and it just returns 'asdsafdfa'.

https://pastebin.com/iDmkugFK

System information

My raspberry pi 400 uses raspbian 64bit, latest

My Python version is 3.9.

My Pip version is latest.

My SpeechRecognition library version is latest.

My PyAudio library version is latest

Bradams2212 avatar May 19 '22 13:05 Bradams2212

The pastebin shows that the c library is having errors. The pi's c library is different sometimes and is not compatible with a lot of libraries.

Ccode-lang avatar May 25 '22 18:05 Ccode-lang

Are you stupid? It's because you have " return 'asdsafdfa' " in your code.

bigboy-baby avatar Feb 05 '23 03:02 bigboy-baby

Are you stupid? It's because you have " return 'asdsafdfa' " in your code.

This is a year old post and I've already resolved the issue. That return line is a flag for the try except lines and I was having issue with the line that converted the audio file to a string. You are a donut.

Bradams2212 avatar Feb 05 '23 03:02 Bradams2212

No shit its a year old, I just had to comment sum because I just dont understand your logic. It says " return 'asdsafdfa' " and ur saying "it not work because it say 'asdsafdfa' 🤓🤓"

bigboy-baby avatar Feb 05 '23 03:02 bigboy-baby

Mate it's a try except block. It executes 'words = parent.r.recognize_google(audioData) #Attempts to convert audio to a string' and in the case that an error occurs, it goes to the exception line which returns an error flag so the program doesn't crash and I can keep testing. Highlighting that it returns the 'asdsafda' string shows that the issue occurs in the try block.

Bradams2212 avatar Feb 05 '23 04:02 Bradams2212

Then don't be a re. U known where the error was coming from so fix it. It not SpeechRecog issue it a u issue it a skill issue.

bigboy-baby avatar Feb 05 '23 20:02 bigboy-baby

Then don't be a re. U known where the error was coming from so fix it. It not SpeechRecog issue it a u issue it a skill issue. Mans mind wandered and never came back. It was a known compatibility issue with the audio drivers

Bradams2212 avatar Feb 06 '23 01:02 Bradams2212

No its not.

bigboy-baby avatar Feb 06 '23 13:02 bigboy-baby