MAZALA2024
commited on
Commit
•
a487ae6
1
Parent(s):
9f55e76
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
-
import numpy as np
|
4 |
-
from scipy.io import wavfile
|
5 |
-
from voice_processing import parallel_tts, get_model_names, voice_mapping
|
6 |
-
from io import BytesIO
|
7 |
import asyncio
|
8 |
import logging
|
|
|
|
|
|
|
|
|
9 |
|
10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
11 |
logger = logging.getLogger(__name__)
|
@@ -18,8 +18,7 @@ async def convert_tts(model_name, tts_text, selected_voice, slang_rate, use_uplo
|
|
18 |
|
19 |
voice_upload_file = None
|
20 |
if use_uploaded_voice and voice_upload is not None:
|
21 |
-
|
22 |
-
voice_upload_file = f.read()
|
23 |
|
24 |
# Create task for parallel processing
|
25 |
task = (
|
@@ -27,7 +26,7 @@ async def convert_tts(model_name, tts_text, selected_voice, slang_rate, use_uplo
|
|
27 |
)
|
28 |
|
29 |
# Asynchronous call to your tts processing function using parallel processing
|
30 |
-
result = await asyncio.
|
31 |
info, _, (tgt_sr, audio_output) = result[0]
|
32 |
|
33 |
return {"info": info}, (tgt_sr, audio_output)
|
@@ -43,23 +42,26 @@ def get_voices():
|
|
43 |
return list(voice_mapping.keys())
|
44 |
|
45 |
# Initialize the Gradio interface
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
gr.
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
if __name__ == "__main__":
|
65 |
-
iface.launch(debug=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
import sys
|
|
|
|
|
|
|
|
|
3 |
import asyncio
|
4 |
import logging
|
5 |
+
from voice_processing import parallel_tts, get_model_names, voice_mapping
|
6 |
+
|
7 |
+
print(f"Python version: {sys.version}")
|
8 |
+
print(f"Gradio version: {gr.__version__}")
|
9 |
|
10 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
11 |
logger = logging.getLogger(__name__)
|
|
|
18 |
|
19 |
voice_upload_file = None
|
20 |
if use_uploaded_voice and voice_upload is not None:
|
21 |
+
voice_upload_file = voice_upload
|
|
|
22 |
|
23 |
# Create task for parallel processing
|
24 |
task = (
|
|
|
26 |
)
|
27 |
|
28 |
# Asynchronous call to your tts processing function using parallel processing
|
29 |
+
result = await asyncio.to_thread(parallel_tts, [task])
|
30 |
info, _, (tgt_sr, audio_output) = result[0]
|
31 |
|
32 |
return {"info": info}, (tgt_sr, audio_output)
|
|
|
42 |
return list(voice_mapping.keys())
|
43 |
|
44 |
# Initialize the Gradio interface
|
45 |
+
with gr.Blocks() as iface:
|
46 |
+
with gr.Row():
|
47 |
+
with gr.Column():
|
48 |
+
model_name = gr.Dropdown(choices=get_models(), label="Model", interactive=True)
|
49 |
+
tts_text = gr.Textbox(label="Text", placeholder="Enter text here")
|
50 |
+
selected_voice = gr.Dropdown(choices=get_voices(), label="Voice", interactive=True)
|
51 |
+
slang_rate = gr.Slider(minimum=0, maximum=1, step=0.01, label="Slang Rate")
|
52 |
+
use_uploaded_voice = gr.Checkbox(label="Use Uploaded Voice")
|
53 |
+
voice_upload = gr.File(label="Voice File")
|
54 |
+
submit_btn = gr.Button("Generate Audio")
|
55 |
+
|
56 |
+
with gr.Column():
|
57 |
+
info_output = gr.JSON(label="Info")
|
58 |
+
audio_output = gr.Audio(label="Generated Audio", type="numpy")
|
59 |
+
|
60 |
+
submit_btn.click(
|
61 |
+
fn=convert_tts,
|
62 |
+
inputs=[model_name, tts_text, selected_voice, slang_rate, use_uploaded_voice, voice_upload],
|
63 |
+
outputs=[info_output, audio_output],
|
64 |
+
api_name="convert_tts"
|
65 |
+
)
|
66 |
|
67 |
+
iface.launch()
|
|
|
|