Python speech_recognition 无法读取wav文件

Python speech_recognition can't not read wav file

我想用recognize_google分析wav文件中的数字

 try:
   temp = r.recognize_google(".//splitAudio//split.wav",language="zh-TW")
   print("You have said \n" + temp )
   print("Audio Recorded Successfully \n ")
 except Exception as e:
   print("Error :  " + str(e))

但我收到以下错误:Error : audio_data must be audio data

这个答案我找了好久,但一直没弄明白。

谁能帮帮我,感激不尽,谢谢

我没有时间安装东西和查找 WAV 文件,但这里是 The Ultimate Guide To Speech Recognition With Python 所说的“使用 record() 从文件中捕获数据”

import speech_recognition as sr
r = sr.Recognizer()
harvard = sr.AudioFile('harvard.wav')
with harvard as source:
    audio = r.record(source)

r.recognize_google(audio)