这是我的代码:
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print('Say Something')
audio = r.listen(source)
voice_data = r.record(audio)
print(voice_data)
Run Code Online (Sandbox Code Playgroud)
当我在终端上输入“python main.py”并启动程序时,它开始监听但没有听懂我说的话。我试过使用adjust_for_ambient_noise() 代替,listen()但它也没有改变任何东西。
我使用的是 macOS Catalina 和 Python 3.8.1。
这是我得到的错误:
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as source:
print('Say Something')
audio = r.listen(source)
voice_data = r.record(audio)
print(voice_data)
Run Code Online (Sandbox Code Playgroud)
这就是我使用时得到的adjust_for_ambient_noise(),如果我使用listen,它不会结束,它只是在听,我以Ctrl+C.
python macos speech-recognition python-3.x speech-recognition-api