Can I use multiple languages for the language detection API in python?

Viewed 151

I'm trying to build my own automatic voice to text translator here is my code so far...

import speech_recognition as sr
from googletrans import Translator
from textblob import TextBlob

translator = Translator()
speech = sr.Recognizer()


with sr.Microphone() as source:
    print("say something!")
    audio = speech.listen(source)
    ToTranslate = speech.recognize_google(audio, language='ko')
    Translate = ToTranslate                            ####^^####
    print(Translate)
    try:
        print("The language used is: " )
        print("You said: " + ToTranslate)
        translation = translator.translate(ToTranslate).text
        print("In english: " + translation)
    except sr.UnknownValueError:
        print("Sorry I can't understand you.")
    except sr.RequestError:
        print("Error")

If I want for it to automatically detect the language, what should I do?

0 Answers
Related