il-hoon commited on
Commit
f7dcd08
·
1 Parent(s): 6511b77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -7
app.py CHANGED
@@ -1,10 +1,52 @@
1
- $git clone https://huggingface.co/spaces/il-hoon/realKtimeKvoice
 
 
 
 
 
2
 
3
- import streamlit as st
4
 
5
- x = st.slider('Select a value')
6
- st.write(x, 'squared is', x * x)
 
 
 
 
 
7
 
8
- $git add app.py
9
- $git commit -m "Add application file"
10
- $git push
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def inference(audio_path, text, mic_path=None):
11
+ if mic_path:
12
+ audio_path = mic_path
13
+ output_path = f"/tmp/output_{uuid.uuid4()}.wav"
14
+ os.system(
15
+ f"python demo_cli.py --no_sound {cpu_param} --audio_path {audio_path} --text {shlex.quote(text.strip())} --output_path {output_path}")
16
+ return output_path
17
 
18
+
19
+ title = "Real-Time-Korea-Voice-Cloning"
20
+ description = "Gradio demo for Real-Time-Korea-Voice-Cloning: Clone a voice in 600 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."
21
+ 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>"
22
+
23
+ examples = [['test.wav', "This is real time voice cloning on huggingface spaces"]]
24
+
25
+
26
+ def toggle(choice):
27
+ if choice == "mic":
28
+ return gr.update(visible=True, value=None), gr.update(visible=False, value=None)
29
+ else:
30
+ return gr.update(visible=False, value=None), gr.update(visible=True, value=None)
31
+
32
+
33
+ with gr.Blocks() as demo:
34
+ with gr.Row():
35
+ with gr.Column():
36
+ radio = gr.Radio(["mic", "file"], value="mic",
37
+ label="How would you like to upload your audio?")
38
+ mic_input = gr.Mic(label="Input", type="filepath", visible=False)
39
+ audio_file = gr.Audio(
40
+ type="filepath", label="Input", visible=True)
41
+ text_input = gr.Textbox(label="Text")
42
+ with gr.Column():
43
+ audio_output = gr.Audio(label="Output")
44
+
45
+ gr.Examples(examples, fn=inference, inputs=[audio_file, text_input],
46
+ outputs=audio_output, cache_examples=True)
47
+ btn = gr.Button("Generate")
48
+ btn.click(inference, inputs=[audio_file,
49
+ text_input, mic_input], outputs=audio_output)
50
+ radio.change(toggle, radio, [mic_input, audio_file])
51
+
52
+ demo.launch(enable_queue=True)