语音识别小程序 识别中英文语音转文字 附python code源码

Описание к видео 语音识别小程序 识别中英文语音转文字 附python code源码

获取麦克风语音 识别并转文字。计划做一个实时翻译英文视频的小程序。还有什么应用场景可以用? 还没想好...
源码:

import speech_recognition as speech #语音转文本库依赖 SpeechRecognition

def rcg_voice():
recog = speech.Recognizer()
#语音来源为麦克风
mic = speech.Microphone()
with mic as source:
recog.adjust_for_ambient_noise(source) # 消除噪音
print('Say Something please:')
while 1:
audio = recog.listen(source)
try:
text = recog.recognize_google(audio,language='zh-cn')
print(text)
except speech.UnknownValueError:
print('Unable to recognize the audio')
except speech.RequestError as e:
print("Request error from Google Speech Recognition service; {}".format(e))

if _name_ == "__main__":
rcg_voice()

Комментарии

Информация по комментариям в разработке