Spaces:
Runtime error
Runtime error
Commit
·
3f204d4
1
Parent(s):
b13fe2e
ignore staff
Browse files
.gitignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
.idea/**
|
2 |
.ipynb_checkpoints/**
|
3 |
nohup.out
|
4 |
-
__pycache__
|
|
|
1 |
.idea/**
|
2 |
.ipynb_checkpoints/**
|
3 |
nohup.out
|
4 |
+
__pycache__/**
|
denoisers/.ipynb_checkpoints/SpectralGating-checkpoint.py
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
import noisereduce as nr
|
2 |
-
import torch
|
3 |
-
import torchaudio
|
4 |
-
|
5 |
-
|
6 |
-
class SpectralGating(torch.nn.Module):
|
7 |
-
"""example: wav_noisy = '/media/public/datasets/denoising/DS_10283_2791/noisy_trainset_56spk_wav/p312_002.wav' """
|
8 |
-
def __init__(self, rate=16000):
|
9 |
-
super(SpectralGating, self).__init__()
|
10 |
-
self.rate = rate
|
11 |
-
|
12 |
-
def forward(self, wav):
|
13 |
-
reduced_noise = torch.Tensor(nr.reduce_noise(y=wav, sr=self.rate))
|
14 |
-
return reduced_noise
|
15 |
-
|
16 |
-
def predict(self, wav_path, out_path):
|
17 |
-
data, rate = torchaudio.load(wav_path)
|
18 |
-
reduced_noise = torch.Tensor(nr.reduce_noise(y=data, sr=rate))
|
19 |
-
torchaudio.save(out_path, reduced_noise, rate)
|
20 |
-
return reduced_noise
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
denoisers/.ipynb_checkpoints/demucs-checkpoint.py
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
import torch
|
2 |
-
|
3 |
-
|
4 |
-
class Encoder(torch.nn.Module):
|
5 |
-
def __init__(self, in_channels, out_channels,
|
6 |
-
kernel_size_1=8, stride_1=4,
|
7 |
-
kernel_size_2=1, stride_2=1):
|
8 |
-
super(Encoder, self).__init__()
|
9 |
-
|
10 |
-
self.conv1 = torch.nn.Conv1d(in_channels=in_channels, out_channels=out_channels,
|
11 |
-
kernel_size=kernel_size_1, stride=stride_1)
|
12 |
-
self.relu1 = torch.nn.ReLU()
|
13 |
-
self.conv2 = torch.nn.Conv1d(in_channels=out_channels, out_channels=2 * out_channels,
|
14 |
-
kernel_size=kernel_size_2, stride=stride_2)
|
15 |
-
self.glu = torch.nn.GLU()
|
16 |
-
|
17 |
-
def forward(self, x):
|
18 |
-
x = self.relu1(self.conv1(x))
|
19 |
-
x = self.glu(self.conv2(x))
|
20 |
-
return x
|
21 |
-
|
22 |
-
|
23 |
-
class Decoder(torch.nn.Module):
|
24 |
-
def __init__(self, in_channels, out_channels,
|
25 |
-
kernel_size_1=3, stride_1=1,
|
26 |
-
kernel_size_2=8, stride_2=4):
|
27 |
-
super(Decoder, self).__init__()
|
28 |
-
|
29 |
-
self.conv1 = torch.nn.Conv1d(in_channels=in_channels, out_channels=2 * in_channels,
|
30 |
-
kernel_size=kernel_size_1, stride=stride_1)
|
31 |
-
self.glu = torch.nn.GLU()
|
32 |
-
self.conv2 = torch.nn.ConvTranspose1d(in_channels=in_channels, out_channels=out_channels,
|
33 |
-
kernel_size=kernel_size_2, stride=stride_2)
|
34 |
-
self.relu = torch.nn.ReLU()
|
35 |
-
|
36 |
-
def forward(self, x):
|
37 |
-
x = self.glu(self.conv1(x))
|
38 |
-
x = self.relu(self.conv2(x))
|
39 |
-
return x
|
40 |
-
|
41 |
-
|
42 |
-
class Demucs(torch.nn.Module):
|
43 |
-
def __init__(self):
|
44 |
-
super(Demucs, self).__init__()
|
45 |
-
|
46 |
-
self.encoder1 = Encoder(in_channels=1, out_channels=64)
|
47 |
-
self.encoder2 = Encoder(in_channels=64, out_channels=128)
|
48 |
-
self.encoder3 = Encoder(in_channels=128, out_channels=256)
|
49 |
-
|
50 |
-
self.lstm = torch.nn.LSTM(input_size=256, hidden_size=256, num_layers=2)
|
51 |
-
|
52 |
-
self.decoder1 = Decoder(in_channels=256, out_channels=128)
|
53 |
-
self.decoder2 = Decoder(in_channels=128, out_channels=64)
|
54 |
-
self.decoder3 = Decoder(in_channels=64, out_channels=1)
|
55 |
-
|
56 |
-
def forward(self, x):
|
57 |
-
out1 = self.encoder1(x)
|
58 |
-
out2 = self.encoder2(out1)
|
59 |
-
out3 = self.encoder3(out2)
|
60 |
-
|
61 |
-
x = self.lstm(out3)
|
62 |
-
|
63 |
-
x = self.decoder1(x + out3)
|
64 |
-
x = self.decoder2(x + out2)
|
65 |
-
x = self.decoder3(x + out1)
|
66 |
-
|
67 |
-
return x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
denoisers/__pycache__/SpectralGating.cpython-38.pyc
DELETED
Binary file (1.2 kB)
|
|
tutorial.ipynb
DELETED
The diff for this file is too large to render.
See raw diff
|
|