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
See original GitHub issuecode
import speech_recognition as sr
r = sr.Recognizer()
with sr.AudioFile("test.wav") as source:
audio = r.record(source)
try:
s = r.recognize_google(audio)
print("Text: "+s)
except Exception as e:
print("Exception: "+str(e))
error
Traceback (most recent call last):
File "/Users/robiulislam/anaconda3/lib/python3.6/site-packages/speech_recognition/__init__.py", line 203, in __enter__
self.audio_reader = wave.open(self.filename_or_fileobject, "rb")
File "/Users/robiulislam/anaconda3/lib/python3.6/wave.py", line 499, in open
return Wave_read(f)
File "/Users/robiulislam/anaconda3/lib/python3.6/wave.py", line 163, in __init__
self.initfp(f)
File "/Users/robiulislam/anaconda3/lib/python3.6/wave.py", line 143, in initfp
self._read_fmt_chunk(chunk)
File "/Users/robiulislam/anaconda3/lib/python3.6/wave.py", line 260, in _read_fmt_chunk
raise Error('unknown format: %r' % (wFormatTag,))
wave.Error: unknown format: 65534
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robiulislam/anaconda3/lib/python3.6/site-packages/speech_recognition/__init__.py", line 208, in __enter__
self.audio_reader = aifc.open(self.filename_or_fileobject, "rb")
File "/Users/robiulislam/anaconda3/lib/python3.6/aifc.py", line 912, in open
return Aifc_read(f)
File "/Users/robiulislam/anaconda3/lib/python3.6/aifc.py", line 351, in __init__
self.initfp(file_object)
File "/Users/robiulislam/anaconda3/lib/python3.6/aifc.py", line 316, in initfp
raise Error('file does not start with FORM id')
aifc.Error: file does not start with FORM id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/robiulislam/anaconda3/lib/python3.6/site-packages/speech_recognition/__init__.py", line 234, in __enter__
self.audio_reader = aifc.open(aiff_file, "rb")
File "/Users/robiulislam/anaconda3/lib/python3.6/aifc.py", line 912, in open
return Aifc_read(f)
File "/Users/robiulislam/anaconda3/lib/python3.6/aifc.py", line 357, in __init__
self.initfp(f)
File "/Users/robiulislam/anaconda3/lib/python3.6/aifc.py", line 314, in initfp
chunk = Chunk(file)
File "/Users/robiulislam/anaconda3/lib/python3.6/chunk.py", line 63, in __init__
raise EOFError
EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "test.py", line 21, in <module>
with sr.AudioFile("test.wav") as source:
File "/Users/robiulislam/anaconda3/lib/python3.6/site-packages/speech_recognition/__init__.py", line 236, in __enter__
raise 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")
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
operating system is Mac & python version 3
Issue Analytics
- State:
- Created 6 years ago
- Reactions:7
- Comments:21
Top Results From Across the Web
Audio file could not be read as PCM WAV, AIFF/AIFF-C, or ...
above is my code,then the error is: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file...
Read more >Python, speech_recognition tool does not recognize .wav file
ValueError : Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another...
Read more >__init__.py · fossasia/SpeechRecognition - Gemfury
Error, EOFError): raise ValueError("Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in...
Read more >Supported Audio File Formats - Ableton
WAV and AIFF (AIFF-C) are the only formats which Live can load without conversion. All other formats are converted into WAV when being...
Read more >Audio file could not be read as PCM WAV, AIFF/AIFF-C, or ...
ValueError : Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
These manipulations helped me to restore the .wav file and the script work!
I fixed it You got the same problem if youre using python 3.7 and above if you use python 3.6 you can run the code