wideband 发表于 2023-3-11 19:17:51

语音识别测试:NameError: name 'recognize_google' is not defined

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
   print('Say Something')
   audio = r.listen(source)
   voice_data = recognize_google(audio)
   print(voice_data)


###############################################

Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\b编程\xx-test\310录音识别播放1.py", line 8, in <module>
    voice_data = recognize_google(audio)
NameError: name 'recognize_google' is not defined

isdkz 发表于 2023-3-11 19:17:52

import speech_recognition as sr

r = sr.Recognizer()

with sr.Microphone() as source:
   print('Say Something')
   audio = r.listen(source)
   voice_data = r.recognize_google(audio)                                       # 这一行少了 r.
   print(voice_data)
页: [1]
查看完整版本: 语音识别测试:NameError: name 'recognize_google' is not defined