Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC
See original GitHub issueI am recording voice using javascript in .wav format:
navigator.mediaDevices.getUserMedia({audio:true})
.then(stream => {handlerFunction(stream)})
function handlerFunction(stream) {
rec = new MediaRecorder(stream);
rec.ondataavailable = e => {
audioChunks.push(e.data);
if (rec.state == "inactive"){
let blob = new Blob(audioChunks,{type:'audio/wav;codecs=0'});
sendData(blob)
}
}
}
sending the file to convert it to text using speech_recognition:
filename = "name.wav"
print(filename)
data = request.body
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
uploadedFile = open(filename, "wb")
uploadedFile.write(request.body)
uploadedFile.close()
#os.path.join(BASE_DIR,filename)
r = sr.Recognizer()
file = sr.AudioFile(filename)
with file as source:
audio = r.record(source)
msg = r.recognize_google(audio)
print(msg)
return redirect('/')
getting 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
audio is saving and sound is clear
audio file:https://drive.google.com/open?id=17ucX9xRG0x5-JEtZDFaotSNLlcRs0jZc
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
ValueError: Audio file could not be read as PCM WAV, AIFF ...
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 >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 >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 >ValueError: Audio file could not be read as PCM WAV, AIFF ...
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
@Asalle @cuongnguyengit u need to install FFmpeg like:= https://github.com/kkroening/ffmpeg-python or from any other repo or lib that use FFmpeg and use it to convert the current file format to PCM WAV, AIFF/AIFF-C, or Native FLAC format before processing it
Can you please tell how you record the audio using js from microphone and convert it to text