【发布时间】:2019-11-26 14:15:52
【问题描述】:
在 Python 中使用 import speech_recognition 时是否可以选择对输出进行分类?
我会很感激这方面的建议,或者是否有可能。
此外,我们将不胜感激任何关于在文本文件中输出此信息的建议,并在每个新扬声器之间添加行。
import speech_recognition as sr
from os import path
from pprint import pprint
audio_file = path.join(path.dirname(path.realpath(__file__)), "RobertP.wav")
r = sr.Recognizer()
with sr.AudioFile(audio_file) as source:
audio = r.record(source)
try:
txt = r.recognize_google(audio, show_all=True)
except:
print("Didn't work.")
text = str(txt)
f = open("tester.txt", "w+")
f.write(text)
f.close()
注意:为我的新手道歉。
【问题讨论】:
标签: python speech-recognition google-speech-api