如何打印从Google Speech API返回的印地文文本 - Python

时间:2017-11-27 09:56:19

标签: python google-speech-api

我在python中使用Google Speech API。在项目I中,将印地语音频转换为文本。我使用language_code="hi-IN" Hindi (India)成功获取转录文本。

但是当我打印时,我得到了这个:

enter image description here

如果我将其复制并粘贴到浏览器上,我可以阅读但无法在终端或文件中打印。我试过这个:

i=0
for result in response.results:
    print('Transcript: {}'.format(result.alternatives[0].transcript))
    print('Confidence: {}'.format(result.alternatives[0].confidence))
    chat_txt = str(result.alternatives[0].transcript)
    ft = open("Response"+str(i)+".txt", "w", encoding="utf-8")
    ft.write(chat_txt)
    ft.write(str(len(chat_txt)))
    ft.close
    i += 1

它只是创建空文件

0 个答案:

没有答案
相关问题