首页 > 解决方案 > 如何使用带有麦克风的模块(语音识别)进行即时转换

问题描述

import speech_recognition

r= speech_recognition.Recognizer()

with speech_recognition.Microphone() as source:
    print("Please wait. Calibrating microphone...") 
    #listen for 5 seconds and create the ambient noise energy level 
    r.adjust_for_ambient_noise(source, duration=5) 
    print("Say something!")
    audio= r.listen(source)

print("Google Speech Recognition thinks you said:")    
result=r.recognize_google(audio, language="zh-TW")
print(result)

如何使用带有麦克风的模块(语音识别)进行即时转换。我尝试使用此模块将语音从计算机麦克风转换为脚本,但它只能在说出整个句子时进行转换。它可以逐字转换吗?

标签: speech-recognitionspeech-to-textvoice-recognitiongoogle-speech-api

解决方案


推荐阅读