Skip to main content

Translate Speech

Change the line 151 in google_trans_new/google_trans_new.py which is: response = (decoded_line + ']') to response = decoded_line 위치는 : /home/pi/.local/lib/python3.9/site-packages/google_trans_new


from google_speech import Speech
from google_trans_new import google_translator  

translator = google_translator()  
translate_text = translator.translate("안녕하세요 ", lang_tgt='en')  


speech = Speech(translate_text, 'en')
speech.play()

print(translate_text)


  • from googletrans import Translator
    from google_speech import Speech
    from time import sleep
    
    stringWord="ダウンタウンD.C.は、ホワイトハウスの近くに抗議し、挑発の別の夜の後に燃えます"
    
    translator = Translator()
    #result = translator.translate('안녕하세요.', dest='ja')
    result = translator.translate(stringWord, dest='ko')
    print(' -> ', result.text)
    speech = Speech(result.text, 'ko')
    speech.play()
    sleep(2)
    result = translator.translate(stringWord, dest='en')
    print(' -> ', result.text)
    speech = Speech(result.text, 'en')
    speech.play()
    sleep(2)
    result = translator.translate(stringWord, dest='ja')
    print(' -> ', result.text)
    speech = Speech(result.text, 'ja')
    speech.play()