M
M
mr_diablol2022-04-16 00:14:19
Python
mr_diablol, 2022-04-16 00:14:19

How to fix error when converting .ogg file using PySoundFile?

Good afternoon. The situation is as follows: I implement in a Python telegram bot the functionality of receiving a voice message (so far on the local disk), processing it (using SpeechRecognition) and responding to the user. However, for this I need to convert the message in .ogg format to .wav (or another that supports the module). I used PySoundFile for this, but it throws an error: RuntimeError: Error opening 'audio.ogg': File contains data in an unimplemented format. The code:

import soundfile as sf
    data, samplerate = sf.read('audio.ogg')
    sf.write('new_file.wav', data, samplerate)


That is, the problem is that a new file with .wav is not created, since .ogg is not readable, but it seems to be.
I did everything according to the documentation: https://pysoundfile.readthedocs.io/en/0.9.0/
This error has already been discussed here: https://qna.habr.com/q/847753 and here https://ru.stackoverflow. com/questions/885549/ogg-... but no solution. Maybe someone came across and somehow coped?
Or is there some other way to convert from .ogg to .wav?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mr_diablol, 2022-04-16
@mr_diablol

Gentlemen, the problem is solved by installing FFmpeg (download and unpack) and adding it to PATH.
Reload pycharm (in my case it was) only, it worked for me after that. If anyone had a warning that it might not work, it will disappear too

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question