"OSError: No Default Input Device Available" on Google Colab
from the above link, I get the record()
function and it is great for reading audio in binary form, but due SpeechRecognition library allowing just (PCM WAV, AIFF/AIFF-C, or Native FLAC) I tried to save the binary as WAV file by add to function:
with open('/content/gtx.wav','wb') as f:
f.write(b)
then all is well, and I found real sound in my drive, but an error appears when trying:
import speech_recognition as sr
r = sr.Recognizer()
temp_voice = sr.AudioFile('/content/gtx.wav')
with temp_voice as file:
audio = r.record(file)
textout=r.recognize_google(audio)
print(textout)
Error:
ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format
So how can I read the audio and directly send it to the SpeechRecognition library? Many thanks for every answer.