Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,23 +1,19 @@
|
|
| 1 |
-
import torch
|
| 2 |
-
import torchaudio
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
torch.
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
target = hifigan(acoustic.generate(hubert.units(source)).transpose(1, 2))
|
| 20 |
-
torchaudio.save("output.wav", target.squeeze(0).cpu(), 16000)
|
| 21 |
-
return "output.wav"
|
| 22 |
-
|
| 23 |
gr.Interface(soft_vc,gr.Audio(label="Input Audio",type="filepath"),gr.Audio(label="Output Audio",type="filepath")).launch()
|
|
|
|
| 1 |
+
import torch
|
| 2 |
+
import torchaudio
|
| 3 |
+
import gradio as gr
|
| 4 |
+
from torchaudio.functional import resample
|
| 5 |
+
hubert = torch.hub.load("bshall/hubert:main", "hubert_soft", trust_repo=True)
|
| 6 |
+
acoustic = torch.hub.load("bshall/acoustic-model:main", "hubert_soft", trust_repo=True)
|
| 7 |
+
hifigan = torch.hub.load("bshall/hifigan:main", "hifigan_hubert_soft", trust_repo=True)
|
| 8 |
+
|
| 9 |
+
@torch.inference_mode()
|
| 10 |
+
def soft_vc(audio_path):
|
| 11 |
+
wav,sr = torchaudio.load(audio_path)
|
| 12 |
+
if sr != 16000:
|
| 13 |
+
resample(wav,sr,16000)
|
| 14 |
+
wav = wav.mean(0,True)
|
| 15 |
+
torchaudio.save("output.wav", hifigan(acoustic.generate(hubert.units(wav.unsqueeze(0))).transpose(1, 2)).squeeze(0), 16000)
|
| 16 |
+
return "output.wav"
|
| 17 |
+
|
| 18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
gr.Interface(soft_vc,gr.Audio(label="Input Audio",type="filepath"),gr.Audio(label="Output Audio",type="filepath")).launch()
|