MiguelZoo commited on
Commit
d15b987
1 Parent(s): 8a79565

Update Music Swap

Browse files
Files changed (1) hide show
  1. Music Swap +61 -1
Music Swap CHANGED
@@ -1 +1,61 @@
1
- <div class="relative cursor-pointer rounded border-2 border-dashed px-3 py-7 text-center text-gray-500 hidden md:block"><span class="pointer-events-none text-sm">Drag image file here or click to browse from your device</span> </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import os
3
+ import shlex
4
+ import gdown
5
+ import uuid
6
+ import torch
7
+
8
+ cpu_param = "--cpu" if not torch.cuda.is_available() else ""
9
+
10
+ if (not os.path.exists("synpretrained.pt")):
11
+ gdown.download("https://drive.google.com/u/0/uc?id=1EqFMIbvxffxtjiVrtykroF6_mUh-5Z3s&export=download&confirm=t",
12
+ "synpretrained.pt", quiet=False)
13
+ gdown.download("https://drive.google.com/uc?export=download&id=1q8mEGwCkFy23KZsinbuvdKAQLqNKbYf1",
14
+ "encpretrained.pt", quiet=False)
15
+ gdown.download("https://drive.google.com/uc?export=download&id=1cf2NO6FtI0jDuy8AV3Xgn6leO6dHjIgu",
16
+ "vocpretrained.pt", quiet=False)
17
+
18
+
19
+ def inference(audio_path, text, mic_path=None):
20
+ if mic_path:
21
+ audio_path = mic_path
22
+ output_path = f"/tmp/output_{uuid.uuid4()}.wav"
23
+ os.system(
24
+ f"python demo_cli.py --no_sound {cpu_param} --audio_path {audio_path} --text {shlex.quote(text.strip())} --output_path {output_path}")
25
+ return output_path
26
+
27
+
28
+ title = "Real-Time-Voice-Cloning"
29
+ description = "Gradio demo for Real-Time-Voice-Cloning: Clone a voice in 5 seconds to generate arbitrary speech in real-time. To use it, simply upload your audio, or click one of the examples to load them. Read more at the links below."
30
+ article = "<p style='text-align: center'><a href='https://matheo.uliege.be/handle/2268.2/6801' target='_blank'>Real-Time Voice Cloning</a> | <a href='https://github.com/CorentinJ/Real-Time-Voice-Cloning' target='_blank'>Github Repo</a></p>"
31
+
32
+ examples = [['test.wav', "This is real time voice cloning on huggingface spaces"]]
33
+
34
+
35
+ def toggle(choice):
36
+ if choice == "mic":
37
+ return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
38
+ else:
39
+ return gr.update(visible=False, value=None), gr.update(visible=True, value=None)
40
+
41
+
42
+ with gr.Blocks() as demo:
43
+ with gr.Row():
44
+ with gr.Column():
45
+ radio = gr.Radio(["mic", "file"], value="mic",
46
+ label="How would you like to upload your audio?")
47
+ mic_input = gr.Mic(label="Input", type="filepath", visible=False)
48
+ audio_file = gr.Audio(
49
+ type="filepath", label="Input", visible=True)
50
+ text_input = gr.Textbox(label="Text")
51
+ with gr.Column():
52
+ audio_output = gr.Audio(label="Output")
53
+
54
+ gr.Examples(examples, fn=inference, inputs=[audio_file, text_input],
55
+ outputs=audio_output, cache_examples=True)
56
+ btn = gr.Button("Generate")
57
+ btn.click(inference, inputs=[audio_file,
58
+ text_input, mic_input], outputs=audio_output)
59
+ radio.change(toggle, radio, [mic_input, audio_file])
60
+
61
+ demo.launch(enable_queue=True)