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

Unable to cast to Tensor #111

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions gen_forward.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@
np.save(str(out_path / f'{wav_name}.npy'), m.numpy(), allow_pickle=False)
elif args.vocoder == 'griffinlim':
wav = dsp.griffinlim(m.squeeze().numpy())
wav=torch.from_numpy(wav) if isinstance(wav,np.ndarray) else wav
wav=wav.unsqueeze(0) if wav.dim() == 1 else wav
dsp.save_wav(wav, out_path / f'{wav_name}.wav')

print('\n\nDone.\n')
2 changes: 2 additions & 0 deletions utils/dsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def load_wav(self, path: Union[str, Path], mono: bool = True) -> torch.Tensor:

def save_wav(self, waveform: torch.Tensor, path: Union[str, Path]) -> None:
"""Save waveform to file"""
if not isinstance(waveform,torch.Tensor):
raise TypeError(f"Expected torch.Tensor, got {type(waveform)}")
torchaudio.save(filepath=path, src=waveform, sample_rate=self.sample_rate)

def adjust_volume(self, waveform: torch.Tensor, target_dbfs: int = -30) -> torch.Tensor:
Expand Down