Amamrnaf
commited on
Commit
·
034f936
1
Parent(s):
cc8d375
touches
Browse files
app.py
CHANGED
@@ -1,24 +1,33 @@
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
23 |
# Gradio interface
|
24 |
with gr.Blocks() as demo:
|
@@ -31,14 +40,14 @@ with gr.Blocks() as demo:
|
|
31 |
speaker_audio = gr.Audio(label="Speaker Audio (to be cloned)",type='filepath', format='wav')
|
32 |
speaker_name = gr.Textbox(label="Speaker Name", placeholder="Enter the speaker's name.")
|
33 |
|
34 |
-
option_selected = gr.Dropdown(choices=["
|
35 |
|
36 |
submit_btn = gr.Button("Submit")
|
37 |
|
38 |
output_audio = gr.Audio(label="Generated Audio Output")
|
39 |
|
40 |
submit_btn.click(
|
41 |
-
|
42 |
inputs=[text_input, speaker_audio, speaker_name, option_selected],
|
43 |
outputs=output_audio,
|
44 |
)
|
|
|
1 |
import gradio as gr
|
2 |
import os
|
3 |
+
from coqui_tts import run_audio_generation_v1
|
4 |
+
|
5 |
+
def process_audio(input_text, speaker_audio, speaker_name, option_selected):
|
6 |
+
try:
|
7 |
+
# Ensure necessary directories exist
|
8 |
+
os.makedirs("./tmp/audio/input_src/", exist_ok=True)
|
9 |
+
os.makedirs("audio", exist_ok=True)
|
10 |
+
|
11 |
+
# Save speaker audio to the required location
|
12 |
+
speaker_audio_path = "./tmp/audio/input_src/0.wav"
|
13 |
+
with open(speaker_audio_path, "wb") as f:
|
14 |
+
f.write(speaker_audio)
|
15 |
+
|
16 |
+
# Check selected option and execute corresponding function
|
17 |
+
if option_selected == "Xtts_v2":
|
18 |
+
# Generate TTS audio using run_audio_generation_v1
|
19 |
+
run_audio_generation_v1(input_text)
|
20 |
+
else:
|
21 |
+
return f"The option '{option_selected}' is not implemented yet."
|
22 |
+
|
23 |
+
# Save the output audio under the speaker's name
|
24 |
+
speaker_output_path = f"audio/{speaker_name}.wav"
|
25 |
+
os.rename("audio/output.wav", speaker_output_path)
|
26 |
+
|
27 |
+
return speaker_output_path
|
28 |
+
|
29 |
+
except Exception as e:
|
30 |
+
return str(e)
|
31 |
|
32 |
# Gradio interface
|
33 |
with gr.Blocks() as demo:
|
|
|
40 |
speaker_audio = gr.Audio(label="Speaker Audio (to be cloned)",type='filepath', format='wav')
|
41 |
speaker_name = gr.Textbox(label="Speaker Name", placeholder="Enter the speaker's name.")
|
42 |
|
43 |
+
option_selected = gr.Dropdown(choices=["Xtts_v2", "metaVoice(not working at the moment)", "more"], label="Select an Option")
|
44 |
|
45 |
submit_btn = gr.Button("Submit")
|
46 |
|
47 |
output_audio = gr.Audio(label="Generated Audio Output")
|
48 |
|
49 |
submit_btn.click(
|
50 |
+
fn=process_audio,
|
51 |
inputs=[text_input, speaker_audio, speaker_name, option_selected],
|
52 |
outputs=output_audio,
|
53 |
)
|