如何解决错误:ValueError:音频文件无法读取为 PCM WAV、AIFF/AIFF-C?
因此,我有使用语音识别将WAV文件变成文本的WAV文件。
import speech_recognition as sr
r = sr.Recognizer()
sample_audio = sr.AudioFile('voice.wav')
print(type(sample_audio))
with sample_audio as audio_file:
audio_content = r.record(audio_file)
print(type(audio_content))
q = r.recognize_google(audio_content)
print(f"You've said: {q}")
但是成功的事实我会遇到一个错误:
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
So I have the WAV file that I need to turn into the text using SpeechRecognition.
import speech_recognition as sr
r = sr.Recognizer()
sample_audio = sr.AudioFile('voice.wav')
print(type(sample_audio))
with sample_audio as audio_file:
audio_content = r.record(audio_file)
print(type(audio_content))
q = r.recognize_google(audio_content)
print(f"You've said: {q}")
But intead of succes I get an error:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论