DEV Community

Cover image for Transcribing Audio in Python
Israel-Lopes
Israel-Lopes

Posted on

3 2

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

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay