Nilani Algiriyage
Nilani Algiriyage

Reputation: 35636

Transcribe an Audio File in Python

I'm trying to transcribe an audio file which is bit large. It's properties are as follows.

Size : 278.3 MB
Duration : 52 minutes
Format : WAV

Follwoing is my code which I used to convert it having 60 second durations. Could you please advice to transcribe this file at once?

import speech_recognition as sr

r = sr.Recognizer()
with sr.AudioFile('sampleMp3.WAV') as source:
    audio = r.record(source, duration=60) 

command = r.recognize_google(audio)

text_file = open("Output.txt", "w")
text_file.write(command)
text_file.close()

Upvotes: 5

Views: 5707

Answers (1)

Nikolay Shmyrev
Nikolay Shmyrev

Reputation: 25210

speech_recognition python package is just a wrapper, it does not provide even basic functions.

If you want to use Google Speech API (paid), you can do something like this:

https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/speech/cloud-client/transcribe_async.py

If you want to consider Bing, it also provides similar API, see How can I transcribe a speech file with the Bing Speech API in Python?

For the free alternative consider https://github.com/alumae/kaldi-offline-transcriber

Upvotes: 3

Related Questions