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: 'WaveUNetModelOutputs' object has no attribute 'output' #22

Closed
karim23657 opened this issue Mar 10, 2024 · 5 comments
Closed

Comments

@karim23657
Copy link

@will-rice , I just got this error,I attached my audio file:
p232.wav.zip

code:

import torch
import torchaudio
from denoisers import WaveUNetModel
from tqdm import tqdm

model = WaveUNetModel.from_pretrained("wrice/waveunet-vctk-24khz")

audio, sr = torchaudio.load("/content/p2325.wav")

if sr != model.config.sample_rate:
    audio = torchaudio.functional.resample(audio, sr, model.config.sample_rate)

chunk_size = model.config.max_length

padding = abs(audio.size(-1) % chunk_size - chunk_size)
padded = torch.nn.functional.pad(audio, (0, padding))

clean = []
for i in tqdm(range(0, padded.shape[-1], chunk_size)):
    audio_chunk = padded[:, i:i + chunk_size]
    with torch.no_grad():
        clean_chunk = model(audio_chunk[None]).audio
    clean.append(clean_chunk.squeeze(0))

denoised = torch.concat(clean, 1)[:, :audio.shape[-1]]

error:

0%|          | 0/1 [00:01<?, ?it/s]

AttributeError        
[p232.wav.zip](https://github.com/will-rice/denoisers/files/14550543/p232.wav.zip)
                    Traceback (most recent call last)
     22         # a=model(audio_chunk[None])
     23         # print(a)
---> 24         clean_chunk = model(audio_chunk[None]).output.audio
     25         # clean_chunk = model(audio_chunk[None]).audio
     26     clean.append(clean_chunk.squeeze(0))

AttributeError: 'WaveUNetModelOutputs' object has no attribute 'output'
@will-rice
Copy link
Owner

will-rice commented Mar 10, 2024

it should be .audio not .output.audio

@karim23657
Copy link
Author

@will-rice , I used .audio in my code, but in issue I pasted my previous console output here,
But now i attached a jupyter notebook to reproduce error:

Open In Colab

this is test audio file:
p232.wav.zip

@will-rice
Copy link
Owner

I didn't publish a new release with the .audio change. A work around is using .logits instead of .audio for version 0.1.6. I'm publishing a release right now with the correction. The latest version 0.1.7 will use .audio

@will-rice
Copy link
Owner

@karim23657 were you able to get this working?

@karim23657
Copy link
Author

@will-rice , thank you . Now working.

import IPython
IPython.display.Audio(denoised.numpy(), rate=model.config.sample_rate)

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