鱼C论坛

 找回密码
 立即注册
查看: 1663|回复: 1

[已解决]语音识别测试:NameError: name 'recognize_google' is not defined

[复制链接]
发表于 2023-3-11 19:17:51 | 显示全部楼层 |阅读模式
10鱼币
  1. import speech_recognition as sr

  2. r = sr.Recognizer()

  3. with sr.Microphone() as source:
  4.      print('Say Something')
  5.      audio = r.listen(source)
  6.      voice_data = recognize_google(audio)
  7.      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
最佳答案
2023-3-11 19:17:52
  1. import speech_recognition as sr

  2. r = sr.Recognizer()

  3. with sr.Microphone() as source:
  4.      print('Say Something')
  5.      audio = r.listen(source)
  6.      voice_data = r.recognize_google(audio)                                       # 这一行少了 r.
  7.      print(voice_data)
复制代码

最佳答案

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2023-3-11 19:17:52 | 显示全部楼层    本楼为最佳答案   
  1. import speech_recognition as sr

  2. r = sr.Recognizer()

  3. with sr.Microphone() as source:
  4.      print('Say Something')
  5.      audio = r.listen(source)
  6.      voice_data = r.recognize_google(audio)                                       # 这一行少了 r.
  7.      print(voice_data)
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-5-1 02:46

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表