hieugiaosu
commited on
Commit
·
3de5b54
1
Parent(s):
9160a00
fix in mix
Browse files
app.py
CHANGED
@@ -24,6 +24,11 @@ def mix(voice1_path, voice2_path, snr=0):
|
|
24 |
global mixed_voice_tool
|
25 |
voice1, _ = load_voice(voice1_path)
|
26 |
voice2, _ = load_voice(voice2_path)
|
|
|
|
|
|
|
|
|
|
|
27 |
mix = torchaudio.functional.add_noise(voice1, voice2, torch.tensor([float(snr)])).float()
|
28 |
mixed_voice_tool = mix
|
29 |
return gr.Audio(tuple((16000,mix[0].numpy())),type='numpy')
|
|
|
24 |
global mixed_voice_tool
|
25 |
voice1, _ = load_voice(voice1_path)
|
26 |
voice2, _ = load_voice(voice2_path)
|
27 |
+
if voice1.shape[-1] != voice2.shape[-1]:
|
28 |
+
if voice1.shape[-1] > voice2.shape[-1]:
|
29 |
+
voice1 = voice1[:,:voice2.shape[-1]]
|
30 |
+
else:
|
31 |
+
voice2 = voice2[:,:voice1.shape[-1]]
|
32 |
mix = torchaudio.functional.add_noise(voice1, voice2, torch.tensor([float(snr)])).float()
|
33 |
mixed_voice_tool = mix
|
34 |
return gr.Audio(tuple((16000,mix[0].numpy())),type='numpy')
|