Transcribing Audio in Python

israellopes

Israel-Lopes

Posted on December 13, 2022

Transcribing Audio in Python

Dependencies

  • build-essential
  • portaudio19-dev
  • pyaudio
  1. sudo apt-get install build-essential
  2. sudo apt install portaudio19-dev
  3. pip install pyaudio

Example


import speech_recognition as sr

r = sr.Recognizer()

while True:
    # Initialize the microphone
    with sr.Microphone() as source:
        print("Speak!!: ")
        audio = r.listen(source)

    try:
        # do the transcription
        transcription = r.recognize_google(audio, language='en-US')
        print(transcription)

    except sr.UnknownValueError:
        print("Didn't understand the audio")

    except sr.RequestError:
        print("request error")

Enter fullscreen mode Exit fullscreen mode

Texto alternativo da imagem)

💖 💪 🙅 🚩
israellopes
Israel-Lopes

Posted on December 13, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related