首页 > 解决方案 > 我需要做什么才能检测到我的麦克风?

问题描述

我厌倦了在 python 中制作一个简单的“语音到文本”程序。正如我所见,这不是一项艰巨的任务,但我的代码不起作用。我没有收到任何错误或警告消息,程序没有在 PyCharm 中检测到我的声音。我检查了我的麦克风,它正在工作。

我的代码:

import speech_recognition as sr

r = sr.Recognizer()
with sr.Microphone() as source:
    print("Speak Anything :")
    audio = r.listen(source)
    try:
        text = r.recognize_google(audio)
        print("You said : {}".format(text))
    except:
        print("Sorry could not recognize what you said")

标签: pythonpycharmspeech-recognitionmicrophone

解决方案


推荐阅读