8

I want to convert an audio(ex: ".mp3") file to text file. I have tried different approaches like pyspeech and speech recognition, But i didn't get any answer. Is there any other way to do this..? Any help would be appreciated !

Kevin
  • 74,910
  • 12
  • 133
  • 166
Mulagala
  • 8,231
  • 11
  • 29
  • 48
  • Possible duplicate: https://stackoverflow.com/questions/12455069/how-to-input-and-process-audio-files-to-convert-to-text-via-pyspeech-or-dragonfl unfortunately without a valid answer. – ρss Sep 15 '15 at 13:22
  • @ρss, Thanks for mentioning but there is also no solid answer – Mulagala Sep 15 '15 at 13:24

3 Answers3

6

Did you try https://pypi.python.org/pypi/SpeechRecognition/ ? That sounds like exactly what you want.

I also found the CMU Sphinx project via this blog. It has Python bindings too (as mentioned in the article).

The other item I found was Google's Speech to Text API. You might want to check that out too. Here's a decent tutorial on this subject:

Mike Driscoll
  • 32,629
  • 8
  • 45
  • 88
  • SpeechRecognition looks like it will do what you want. Note that it uses external speech to text engines on the web, so you'll need internet access and a key for whatever service option you use.Textract (http://textract.readthedocs.org/en/latest/) provides a simple, uniform interface for text extraction and uses SpeechRecognition for handling audio files. – ViennaMike Dec 23 '15 at 18:18
2
import speech_recognition as sr
print(sr.__version__)
r = sr.Recognizer()

file_audio = sr.AudioFile('file_audio.wav')

with file_audio as source:
   audio_text = r.record(source)

print(type(audio_text))
print(r.recognize_google(audio_text))
kamran kausar
  • 4,117
  • 1
  • 23
  • 17
  • Do you know if is there a workaround to other idioms (portuguese) using Sphinx? –  Nov 22 '19 at 14:39
0

way 1: convet audio file to bytes (0,1) with https://github.com/jiaaro/pydub or by f = open("test.mp3", "rb") first16bytes = f.read(16)

way 2: audio to speech convertors.eg.-convert to english or other language with pip libraries like SpeechRecognition pydub. (but i think you don't asked for this)

way 3: convert mp3 to Json. If anyone did this, then please share.