Search code examples
pythonlibrosaopus

reading .opus audio files in python


I'm trying to use librosa to read an .opus file but it runs forever and doesn't load anything (I've waited for around 30 minutes for a 51MB file and still nothing).

Here is the code I am using

path_to_opus = '/my/path/to/file.opus'
y, sr = librosa.load(path_to_opus, sr=16000)

Is there a good way of reading .opus audio files in python fast?

Thanks!


Solution

  • By looking at the librosa documentation you can specify a res_type field that sounds to be useful for you. This is a quote from the doc:

    res_type : str

    By default, this uses resampy’s high-quality mode (‘kaiser_best’).

    To use a faster method, set res_type=’kaiser_fast’.

    To use scipy.signal.resample, set res_type=’scipy’.

    You could try something like:

    X, sr = librosa.load('myfile.opus', res_type='kaiser_fast', ...)