从连续的语音到文本写入文本 [英] Writing to text from continuous speech-to-text

查看:92
本文介绍了从连续的语音到文本写入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试修改来自https:// github(dot)com / Azure-Samples / cognitive-services-speech-sdk / tree / master / samples / python / console的speech_sample.py 获取连续的语音到文本转录的结果并将其打印到文件中。至于
我可以告诉,< b / b>

I'm trying to modify the speech_sample.py from https://github (dot) com/Azure-Samples/cognitive-services-speech-sdk/tree/master/samples/python/console to take the result of continuous speech-to-text transcription and print it to a file. As far as I can tell, the 

speech_recognizer.recognized.connect(lambda evt: print('RECOGNIZED: {}'.format(evt)))

以特定的格式。由于印刷格式具有"文本",因此类别,我希望
只获取转录文本并将其附加到文本文件中。任何有关如何完成此任务的帮助将不胜感激!

from the speech_recognize_continuous_from_file(): section takes the output once the system sends back a recognized utterance and prints it to the command line in a specific format. Since the printed format has a "text" category, I was hoping to take just the transcribed text and append it to a text file. Any help with how to accomplish this would be greatly appreciated!

推荐答案

你好,

你可以添加这个简单的代码来获取文件中的文本。 

You can just add this simple code to get the text in file. 

    print("Inside speech_recognize_once_from_file()")
    f1=open('./testfile', 'w+')
    f1.write(result.text)
    f1.close()




重新运行应用程序后。它应该将注释和文本打印到文件中。

Once you re-run the application. It should print the comment and the text to the file.


这篇关于从连续的语音到文本写入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆