Python Forum

Full Version: Getting MemoryError frames.write(buffer)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying to use the code given in below link: https://pypi.org/project/SpeechRecognition/1.2.3/

Below is the code:


import speech_recognition as sr
r = sr.Recognizer()
with sr.WavFile("audio.wav") as source:              # use "test.wav" as the audio source
    audio = r.record(source)                        # extract audio data from the file

try:
    print("Transcription: " + r.recognize(audio))   # recognize speech using Google Speech Recognition
except LookupError:                                 # speech is unintelligible
    print("Could not understand audio")
But it ran into below error:

Quote:>python s2t.py
Traceback (most recent call last):
File "s2t.py", line 4, in <module>
audio = r.record(source) # extract audio data from the file
File "C:\Users\<myuser>\AppData\Local\Programs\Python\Python36-32\lib\site-packages\speech_recognition\__init__.py", line 504, in record
frames.write(buffer)
MemoryError

Can you please suggest how to resolve this memory or code error?

Few other details:

1. I am on windows 10
2. I tried replacing recognize(audio) with recognize_google(audio) . Same error.
3. The size of audio.wav is 750MB. I have 16GB ram on my PC.

Thanks.