首页 > 解决方案 > python中的语音翻译器

问题描述

我已经使用此代码-https ://github.com/Alekh-sinha/google_translator/blob/master/text_to_speech_3.py进行语音翻译。它基本上将语音转换为文本,然后翻译该文本,然后将翻译后的文本转换回声音。我想将它用于在我的 PC 上运行的视频,所以我在我的 PC 中启用了立体声混音并且它有效。但是当我将相同的主体应用于Skype通话时,它不起作用。我将非常感谢有人会在这方面帮助我

标签: pythongoogle-cloud-platformspeech-recognitionspeech

解决方案


我已经尝试过了,但由于 Python 版本不同,它不起作用。所以最好在没有 API 的情况下制作一个翻译器,它的代码在这里,但首先进入你的终端并输入 pip install googletrans:

from googletrans import Translator

while True:
        sentence=str(input("say..."))
        translator=Translator()
        translated_sentence=translator.translate(sentence,src='en',dest='hi')
        print(translated_sentence.text)

推荐阅读