I would like to translate the audio data directly with recognize_google function without saving the audio data to wav.file format.
Steps to reproduce
def save_chunk(fr,chunk_no,rate,p,r):
'''
This function will take the frames for the each chunk and saves the file in the folder
then extract the spoken text from the file and displays the text.
Question : Can i extract the audio from frames directly using same methodology without having to
create audio files in the folder?
'''
print("this has recived {} frames".format(len(fr)))
try:
chunk_name = "Chunks/chunk_{}.wav".format(chunk_no)
wf = wave.open(chunk_name, 'wb')
wf.setnchannels(1)
wf.setsampwidth(p.get_sample_size(pyaudio.paInt16))
wf.setframerate(rate)
wf.writeframes(b''.join(fr))
wf.close()
with sr.AudioFile(chunk_name) as source:
audio = r.listen(source)
text = r.recognize_google(audio)
print(text)
except Exception as e:
print("No Audio Detected",e)
Expected behaviour
(What did you expect to happen?)
Actual behaviour
(What happened instead? How is it different from what you expected?)
(If the library threw an exception, paste the full stack trace here)
System information
(Delete all the statements that don't apply.)
My system is . (For example, "Ubuntu 16.04 LTS x64", "Windows 10 x64", or "macOS Sierra".)
Windows 10 x64
My Python version is . (You can check this by running python -V.)
Python 3.8.5
My Pip version is . (You can check this by running pip -V.)
21.0.1
My SpeechRecognition library version is . (You can check this by running python -c "import speech_recognition as sr;print(sr.__version__)".)
3.8.1
My PyAudio library version is / I don't have PyAudio installed. (You can check this by running python -c "import pyaudio as p;print(p.__version__)".)
0.2.11
My microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())".)
My working microphones are: (You can check this by running python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())".)
I installed PocketSphinx from. (For example, from the Debian repositories, from Homebrew, or from the source code.)
I would like to translate the audio data directly with recognize_google function without saving the audio data to wav.file format.
Steps to reproduce
def save_chunk(fr,chunk_no,rate,p,r): ''' This function will take the frames for the each chunk and saves the file in the folder then extract the spoken text from the file and displays the text. Question : Can i extract the audio from frames directly using same methodology without having to create audio files in the folder? '''
print("this has recived {} frames".format(len(fr)))
Expected behaviour
(What did you expect to happen?)
Actual behaviour
(What happened instead? How is it different from what you expected?)
System information
(Delete all the statements that don't apply.)
My system is. (For example, "Ubuntu 16.04 LTS x64", "Windows 10 x64", or "macOS Sierra".)
Windows 10 x64
My Python version is . (You can check this by running . (You can check this by running . (You can check this by running / I don't have PyAudio installed. (You can check this by running
python -V
.) Python 3.8.5 My Pip version ispip -V
.) 21.0.1 My SpeechRecognition library version ispython -c "import speech_recognition as sr;print(sr.__version__)"
.) 3.8.1 My PyAudio library version ispython -c "import pyaudio as p;print(p.__version__)"
.) 0.2.11 My microphones are: (You can check this by runningpython -c "import speech_recognition as sr;print(sr.Microphone.list_microphone_names())"
.)My working microphones are: (You can check this by running
python -c "import speech_recognition as sr;print(sr.Microphone.list_working_microphones())"
.)I installed PocketSphinx from. (For example, from the Debian repositories, from Homebrew, or from the source code.)