Converting audio file to text

Hi @soadadfarhan,

The second example on the speech_recognition home page looks like it would do what you want. In particular, it seems that you need to ‘record’ the contents of the audio file using the Recognizer:

    r = sr.Recognizer()
    with anvil.media.TempFile(AudioFile) as file_name:
      with sr.AudioFile(file_name) as source:
        audio = r.record(source)
    response = r.recognize_google(audio)

Hopefully that should do roughly what you want! If you still see errors, then @stucork is right - please post a clone link to a minimal example here.

2 Likes