Answer the question
In order to leave comments, you need to log in
Is there a Python speech recognition library that supports the ogg file format?
You need a library for speech recognition (or processing an audio file) and outputting content to text (similar to the Python library SpeechRecognizer)
It is imperative that the library can work with ogg files. If anyone has any ideas, I'd be happy to advise, thanks)))
Answer the question
In order to leave comments, you need to log in
You will need to install ffmpeg from ffmpeg
Unpack and add to PATH
from subprocess import Popen
from speech_recognition import (Recognizer, AudioFile)
from speech_recognition import (UnknownValueError, RequestError)
class SpeechOggAudioFileToText:
def __init__(self):
self.recognizer = Recognizer()
def ogg_to_wav(self, file):
args = ['ffmpeg','-i', file, 'test.wav']
process = Popen(args)
process.wait()
@property
def text(self):
AUDIO_FILE = 'test.wav'
with AudioFile(AUDIO_FILE) as source:
audio = self.recognizer.record(source)
try:
text = self.recognizer.recognize_google(audio, language='RU')
return text
except UnknownValueError:
print("Не удаётся распознать аудио файл")
except RequestError as error:
print("Не удалось запросить результаты: {0}".format(error))
def main():
speech_ogg = SpeechOggAudioFileToText()
speech_ogg.ogg_to_wav('test.ogg')
print(speech_ogg.text)
if __name__ == '__main__':
main()
I don't know of a speech recognition library with .ogg support, but maybe I can help. In Python it is possible to convert .ogg to .wav and already use .wav for Speech to Text.
import soundfile
data, samplerate = soundfile.read('yourfile.ogg')
soundfile.write('newfile.wav', data, samplerate)
data, samplerate = soundfile.read('newfile.wav')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question