Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AttributeError: module 'librosa' has no attribute 'output'

I am using librosa 0.6 in anaconda and i have also installed ffmpeg but i am still getting this error

the code is

a = np.exp(spectrum) - 1
    p = 2 * np.pi * np.random.random_sample(spectrum.shape) - np.pi
    for i in range(50):
        S = a * np.exp(1j * p)
        x = librosa.istft(S)
        p = np.angle(librosa.stft(x, N_FFT))
    librosa.output.write_wav(outfile, x, sr)

like image 374
Aditya Kumar Avatar asked Sep 21 '20 18:09

Aditya Kumar


People also ask

What is Librosa in Python?

Librosa is a Python package for music and audio analysis. Librosa is basically used when we work with audio data like in music generation(using LSTM's), Automatic Speech Recognition. It provides the building blocks necessary to create the music information retrieval systems.

How install Librosa Linux?

If you intend to develop librosa or make changes to the source code, you can install with pip install -e to link to your actively developed source tree: tar xzf librosa-VERSION. tar. gz cd librosa-VERSION/ pip install -e .

What does Librosa load do?

load. Load an audio file as a floating point time series. Audio will be automatically resampled to the given rate (default sr=22050 ).


Video Answer


2 Answers

you can use this instead

import soundfile as sf
sf.write('stereo_file1.wav', reduced_noise, 48000, 'PCM_24')

check more here https://pysoundfile.readthedocs.io/en/0.8.1/#soundfile.write

like image 125
ANAS.C Avatar answered Sep 22 '22 11:09

ANAS.C


librosa.output was removed in librosa version 0.8.0. This is documented in their changelog. So the most likely reason for your issue is that you are using this new version of librosa (and not version 0.6.x). You can verify by doing print(librosa.__version__).

With moden librosa, you should instead use soundfile.write to write audio output.

like image 26
Jon Nordby Avatar answered Sep 20 '22 11:09

Jon Nordby