Search code examples
pythonspeech-recognitiontext-to-speech

Speech recognization other languages apart from English in python


I am trying to convert audio to text. The audio is not in English but in Dutch. I am unable to convert the Dutch audio to text. The code works only for English audios. I am not sure if I need to include some functions or options for the code to recognise other languages as well. Below is the code:

import speech_recognition as sr

r = sr.Recognizer()

with sr.AudioFile('audio.wav') as source:
    audio = r.listen(source)
    try:
        text = (r.recognize_google)
        print(text)

Solution

  • Use:

    text = r.recognize_google(audio, language="nl-NL")