Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ljy-002 opened this issue Feb 20, 2022 · 4 comments
Open

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

ljy-002 opened this issue Feb 20, 2022 · 4 comments

Comments

@ljy-002
Copy link

ljy-002 commented Feb 20, 2022

"librosa.output" was removed in librosa version 0.8.0. This is documented in their changelog


F:\【密】AI-人工智能\WaveRNN>python quick_start.py
Using device: cpu

Initialising WaveRNN Model...

Trainable Parameters: 4.234M

Initialising Tacotron Model...

Trainable Parameters: 11.088M
F:\【密】AI-人工智能\WaveRNN\models\tacotron.py:308: UserWarning: To copy construct from a tensor, it is recommended to use sourceTensor.clone().detach() or sourceTensor.clone().detach().requires_grad_(True), rather than tensor.new_tensor(sourceTensor).
self.decoder.r = self.decoder.r.new_tensor(value, requires_grad=False)
+---------+---------------+-----------------+----------------+-----------------+
| WaveRNN | Tacotron(r=2) | Generation Mode | Target Samples | Overlap Samples |
+---------+---------------+-----------------+----------------+-----------------+
| 797k | 180k | Unbatched | N/A | N/A |
+---------+---------------+-----------------+----------------+-----------------+

| Generating 1/6
| ████████████████ 87400/87450 | Batch Size: 1 | Gen Rate: 0.0kHz | Traceback (most recent call last):
File "F:\【密】AI-人工智能\WaveRNN\quick_start.py", line 120, in
voc_model.generate(m, save_path, batched, 11_000, 550, hp.mu_law)
File "F:\【密】AI-人工智能\WaveRNN\models\fatchord_version.py", line 260, in generate
save_wav(output, save_path)
File "F:\【密】AI-人工智能\WaveRNN\utils\dsp.py", line 23, in save_wav
librosa.output.write_wav(path, x.astype(np.float32), sr=hp.sample_rate)
AttributeError: module 'librosa' has no attribute 'output'

@ljy-002
Copy link
Author

ljy-002 commented Feb 20, 2022

I forgot what I spent an hour doing on the computer


The error changed:
cmd: python quick_start.py -u --input_text "如果我运行这个命令会发生什么?"
error:
Traceback (most recent call last):
File "F:\【密】AI-人工智能\WaveRNN\quick_start.py", line 2, in
from models.fatchord_version import WaveRNN
File "F:\【密】AI-人工智能\WaveRNN\models\fatchord_version.py", line 6, in
from utils.dsp import *
File "F:\【密】AI-人工智能\WaveRNN\utils\dsp.py", line 3, in
import librosa
File "D:\PROG\Python\Python-3.9.10\lib\site-packages\librosa_init_.py", line 12, in
from . import core
File "D:\PROG\Python\Python-3.9.10\lib\site-packages\librosa\core_init_.py", line 109, in
from .time_frequency import * # pylint: disable=wildcard-import
File "D:\PROG\Python\Python-3.9.10\lib\site-packages\librosa\core\time_frequency.py", line 10, in
from ..util.exceptions import ParameterError
File "D:\PROG\Python\Python-3.9.10\lib\site-packages\librosa\util_init_.py", line 71, in
from . import decorators
File "D:\PROG\Python\Python-3.9.10\lib\site-packages\librosa\util\decorators.py", line 9, in
from numba.decorators import jit as optional_jit
ModuleNotFoundError: No module named 'numba.decorators'

@ljy-002
Copy link
Author

ljy-002 commented Feb 20, 2022

Oh, I remembered, I changed the requirements.txt
Changed from numpy==xxx to numpy==1.21.5

@ljy-002
Copy link
Author

ljy-002 commented Feb 20, 2022

哦,我想起来了,我把requirements.txt 从numpy==xxx改成了numpy==1.21.5

Numpy-Issuse

@terminatormlp
Copy link

  1. First install suondfile
    pip install soundfile

Update the save_wav function:
2. Now, you need to update the save_wav function in your dsp.py file to use the soundfile.write function instead of the deprecated librosa.output.write_wav function.

3.Open your dsp.py file and locate the save_wav function. Replace its content with the following updated code:
dsp.py <- it's located in utils\dsp.py

import numpy as np
import soundfile as sf  # Import soundfile module

# ... (other functions remain the same) ...

def save_wav(x, path): #22 line
    sf.write(path, x.astype(np.float32), hp.sample_rate, format='wav')

# ... (other functions remain the same) ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants