def audio_to_text(outname):
import speech_recognition as sr
r = sr.Recognizer()
with sr.WavFile(outname) as source:
audio = r.record(source)
try:
command = r.recognize_google(audio,language='pt_BR')
if not command.isspace():
report(now,command.encode('utf-8'))
log = '%s>>>%s\n' %(now,command.encode('utf-8'))
report(log)
except Exception as e:
print str(e)
os.remove(outname)
评论列表
文章目录