Comments (6)
I removed all CUDA specific code from glow.py and inference.py , it runs now but the wave file generated is full of NULL , so no speech in it.
Any idea what could be the issue?
diff --git a/denoiser.py b/denoiser.py
index 8f9ff57..2da8f3a 100644
--- a/denoiser.py
+++ b/denoiser.py
@@ -11,7 +11,7 @@ class Denoiser(torch.nn.Module):
super(Denoiser, self).__init__()
self.stft = STFT(filter_length=filter_length,
hop_length=int(filter_length/n_overlap),
- win_length=win_length).cuda()
+ win_length=win_length)
if mode == 'zeros':
mel_input = torch.zeros(
(1, 80, 88),
@@ -32,7 +32,7 @@ class Denoiser(torch.nn.Module):
self.register_buffer('bias_spec', bias_spec[:, :, 0][:, :, None])
def forward(self, audio, strength=0.1):
- audio_spec, audio_angles = self.stft.transform(audio.cuda().float())
+ audio_spec, audio_angles = self.stft.transform(audio.float())
audio_spec_denoised = audio_spec - self.bias_spec * strength
audio_spec_denoised = torch.clamp(audio_spec_denoised, 0.0)
audio_denoised = self.stft.inverse(audio_spec_denoised, audio_angles)
diff --git a/glow.py b/glow.py
index f692103..6690272 100644
--- a/glow.py
+++ b/glow.py
@@ -103,7 +103,7 @@ class Invertible1x1Conv(torch.nn.Module):
# Reverse computation
W_inverse = W.float().inverse()
W_inverse = Variable(W_inverse[..., None])
- if z.type() == 'torch.cuda.HalfTensor':
+ if z.type() == 'torch.HalfTensor':
W_inverse = W_inverse.half()
self.W_inverse = W_inverse
z = F.conv1d(z, self.W_inverse, bias=None, stride=1, padding=0)
@@ -148,8 +148,8 @@ class WN(torch.nn.Module):
# depthwise separable convolution
depthwise = torch.nn.Conv1d(n_channels, n_channels, 3,
dilation=dilation, padding=padding,
- groups=n_channels).cuda()
- pointwise = torch.nn.Conv1d(n_channels, 2*n_channels, 1).cuda()
+ groups=n_channels)
+ pointwise = torch.nn.Conv1d(n_channels, 2*n_channels, 1)
bn = torch.nn.BatchNorm1d(n_channels)
self.in_layers.append(torch.nn.Sequential(bn, depthwise, pointwise))
# res_skip_layer
@@ -245,12 +245,12 @@ class SqueezeWave(torch.nn.Module):
def infer(self, spect, sigma=1.0):
spect_size = spect.size()
l = spect.size(2)*(256 // self.n_audio_channel)
- if spect.type() == 'torch.cuda.HalfTensor':
- audio = torch.cuda.HalfTensor(spect.size(0),
+ if spect.type() == 'torch.HalfTensor':
+ audio = torch.HalfTensor(spect.size(0),
self.n_remaining_channels,
l).normal_()
else:
- audio = torch.cuda.FloatTensor(spect.size(0),
+ audio = torch.FloatTensor(spect.size(0),
self.n_remaining_channels,
l).normal_()
@@ -268,10 +268,10 @@ class SqueezeWave(torch.nn.Module):
audio = self.convinv[k](audio, reverse=True)
if k % self.n_early_every == 0 and k > 0:
- if spect.type() == 'torch.cuda.HalfTensor':
- z = torch.cuda.HalfTensor(spect.size(0), self.n_early_size, l).normal_()
+ if spect.type() == 'torch.HalfTensor':
+ z = torch.HalfTensor(spect.size(0), self.n_early_size, l).normal_()
else:
- z = torch.cuda.FloatTensor(spect.size(0), self.n_early_size, l).normal_()
+ z = torch.FloatTensor(spect.size(0), self.n_early_size, l).normal_()
audio = torch.cat((sigma*z, audio),1)
audio = audio.permute(0,2,1).contiguous().view(audio.size(0), -1).data
diff --git a/inference.py b/inference.py
index 568e6ce..f31c013 100644
--- a/inference.py
+++ b/inference.py
@@ -32,27 +32,31 @@ from scipy.io.wavfile import write
import torch
from mel2samp import files_to_list, MAX_WAV_VALUE
from denoiser import Denoiser
-
+import time
def main(mel_files, squeezewave_path, sigma, output_dir, sampling_rate, is_fp16,
denoiser_strength):
mel_files = files_to_list(mel_files)
- squeezewave = torch.load(squeezewave_path)['model']
+
+ #device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
+ device = torch.device('cpu')
+ squeezewave = torch.load(squeezewave_path,map_location=device) ['model']
squeezewave = squeezewave.remove_weightnorm(squeezewave)
- squeezewave.cuda().eval()
+ squeezewave.eval()
if is_fp16:
from apex import amp
- squeezewave, _ = amp.initialize(squeezewave, [], opt_level="O3")
+ squeezewave, _ = amp.initialize(squeezewave, [])
if denoiser_strength > 0:
- denoiser = Denoiser(squeezewave).cuda()
-
+ denoiser = Denoiser(squeezewave)
+ start = time.time()
for i, file_path in enumerate(mel_files):
file_name = os.path.splitext(os.path.basename(file_path))[0]
mel = torch.load(file_path)
- mel = torch.autograd.Variable(mel.cuda())
+ mel = torch.autograd.Variable(mel)
mel = torch.unsqueeze(mel, 0)
mel = mel.half() if is_fp16 else mel
+
with torch.no_grad():
audio = squeezewave.infer(mel, sigma=sigma).float()
if denoiser_strength > 0:
@@ -65,6 +69,9 @@ def main(mel_files, squeezewave_path, sigma, output_dir, sampling_rate, is_fp16,
output_dir, "{}_synthesis.wav".format(file_name))
write(audio_path, sampling_rate, audio)
print(audio_path)
+ end = time.time()
+ print("Squeezewave vocoder time")
+ print(end-start)
if __name__ == "__main__":
from squeezewave.
ok i was able to solve it ,
diff is here
https://github.com/alokprasad/binaries/blob/master/squeezewave.diff
I will request a pull request for the same .
from squeezewave.
@varungujjar you can use this repo , have put all the changes there https://github.com/alokprasad/fastspeech_squeezewave
from squeezewave.
Thank you so much for your attention to our work, and you are right, if you want to run it on CPU, you need to delete all .cuda(), and change all Cuda tensors to normal tensors.
from squeezewave.
@alokprasad I made the changes as per the https://github.com/alokprasad/binaries/blob/master/squeezewave.diff
removed all references to cuda ..however am still unable to run the model using this command
python inference.py -f <(ls mel_spectrograms/*.pt) -w L64_large_pretrain -o . --is_fp16 -s 0.6
File "inference.py", line 92, in
args.sampling_rate, args.is_fp16, args.denoiser_strength)
File "inference.py", line 46, in main
squeezewave, _ = amp.initialize(squeezewave,[],opt_level="O3")
File "/Volumes/Work/dev/SqueezeWave/env/lib/python3.7/site-packages/apex-0.1-py3.7.egg/apex/amp/frontend.py", line 358, in initialize
return _initialize(models, optimizers, _amp_state.opt_properties, num_losses, cast_model_outputs)
File "/Volumes/Work/dev/SqueezeWave/env/lib/python3.7/site-packages/apex-0.1-py3.7.egg/apex/amp/_initialize.py", line 171, in _initialize
check_params_fp32(models)
File "/Volumes/Work/dev/SqueezeWave/env/lib/python3.7/site-packages/apex-0.1-py3.7.egg/apex/amp/_initialize.py", line 93, in check_params_fp32
name, param.type()))
File "/Volumes/Work/dev/SqueezeWave/env/lib/python3.7/site-packages/apex-0.1-py3.7.egg/apex/amp/_amp_state.py", line 32, in warn_or_err
raise RuntimeError(msg)
RuntimeError: Found param WN.0.in_layers.0.0.weight with type torch.FloatTensor, expected torch.cuda.FloatTensor.
When using amp.initialize, you need to provide a model with parameters
located on a CUDA device before passing it no matter what optimization level
you chose. Use model.to('cuda') to use the default device.
How did u solve it ? did i miss anything ?
from squeezewave.
@alokprasad great ... also just refered to your page i'll be trying this on a RPI4 4gb and get back to you with the timing .. :)
from squeezewave.
Related Issues (20)
- How long does a training from scratch take? HOT 2
- Slower than Waveglow on GPU
- how to use squeezewave with tts to generate voice HOT 3
- Loss calculation HOT 1
- want to see some speed tests
- hop_length
- [Question] published latency/delay of SW for real-time streaming inference
- License
- [Question] MOS results HOT 1
- why is "segment_length" set to 16384? HOT 1
- Docker
- Parameter configs for different sample rate, hop length etc.
- bias from the model
- 'Upsample1d' object has no attribute 'weight'
- denoiser of the squeezewave HOT 1
- train.py
- wav have no voice
- convert squeezewave model to pytorch script for C++ inference. HOT 4
- preprocess HOT 2
- Question if the code line is a typo or not.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from squeezewave.