import googletrans
import speech_recognition
import gtts
import playsound
print (googletrans.LANGUAGES)
input_lang = input("Please type input language name: ")
output_lang = input("Please type output language name: ")
recognizer = speech_recognition.Recognizer()
with speech_recognition.Microphone () as source:
print ("speak now")
voice = recognizer.listen(source)
text = recognizer.recognize_google(voice, language=input_lang)
print (text)
translator = googletrans. Translator()
translation = translator.translate(text, dest=output_lang)
print (translation.text)
converted_audio = gtts.gTTS(translation.text, lang=output_lang)
converted_audio.save("hello.mp3")
playsound.playsound("hello.mp3")
How to create Voice Translator using Python
Here's code for Voice Translator:
You need to install some requirements (googletrans,
speech recognition, gtts, playsound modules) for this voice translator.
I hope this helps! To make a voice translator in python.
