Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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()
like image 576
Nilani Algiriyage Avatar asked Oct 17 '22 06:10

Nilani Algiriyage


1 Answers

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

like image 111
Nikolay Shmyrev Avatar answered Nov 04 '22 19:11

Nikolay Shmyrev