Spaces:
Runtime error
Runtime error
m4jbz
commited on
Commit
•
9ab1546
1
Parent(s):
6002d90
test
Browse files
app.py
CHANGED
@@ -56,6 +56,18 @@ css = """
|
|
56 |
"""
|
57 |
|
58 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
59 |
def build_html_output(s: str, style: str = "result_item_success"):
|
60 |
return f"""
|
61 |
<div class='result'>
|
@@ -66,12 +78,13 @@ def build_html_output(s: str, style: str = "result_item_success"):
|
|
66 |
"""
|
67 |
|
68 |
|
69 |
-
def process(language: str, repo_id: str, text: str, speed: float):
|
70 |
-
logging.info(f"Input text: {text}.
|
|
|
71 |
tts = get_pretrained_model(repo_id, speed)
|
72 |
|
73 |
start = time.time()
|
74 |
-
audio = tts.generate(text)
|
75 |
end = time.time()
|
76 |
|
77 |
if len(audio.samples) == 0:
|
@@ -91,7 +104,7 @@ def process(language: str, repo_id: str, text: str, speed: float):
|
|
91 |
"""
|
92 |
|
93 |
logging.info(info)
|
94 |
-
logging.info(f"\nrepo_id: {repo_id}\ntext: {text}\nspeed: {speed}")
|
95 |
|
96 |
filename = str(uuid.uuid4())
|
97 |
filename = f"{filename}.wav"
|
@@ -110,6 +123,25 @@ demo = gr.Blocks(css=css)
|
|
110 |
|
111 |
with demo:
|
112 |
gr.Markdown(title)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
|
114 |
with gr.Tabs():
|
115 |
with gr.TabItem("Por favor ingresa tu texto"):
|
@@ -120,6 +152,16 @@ with demo:
|
|
120 |
placeholder="Por favor ingresa tu texto aquí",
|
121 |
)
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
input_speed = gr.Slider(
|
124 |
minimum=0.1,
|
125 |
maximum=10,
|
@@ -137,7 +179,10 @@ with demo:
|
|
137 |
input_button.click(
|
138 |
process,
|
139 |
inputs=[
|
|
|
|
|
140 |
input_text,
|
|
|
141 |
input_speed,
|
142 |
],
|
143 |
outputs=[
|
|
|
56 |
"""
|
57 |
|
58 |
|
59 |
+
def update_model_dropdown(language: str):
|
60 |
+
if language in language_to_models:
|
61 |
+
choices = language_to_models[language]
|
62 |
+
return gr.Dropdown(
|
63 |
+
choices=choices,
|
64 |
+
value=choices[0],
|
65 |
+
interactive=True,
|
66 |
+
)
|
67 |
+
|
68 |
+
raise ValueError(f"Unsupported language: {language}")
|
69 |
+
|
70 |
+
|
71 |
def build_html_output(s: str, style: str = "result_item_success"):
|
72 |
return f"""
|
73 |
<div class='result'>
|
|
|
78 |
"""
|
79 |
|
80 |
|
81 |
+
def process(language: str, repo_id: str, text: str, sid: str, speed: float):
|
82 |
+
logging.info(f"Input text: {text}. sid: {sid}, speed: {speed}")
|
83 |
+
sid = int(sid)
|
84 |
tts = get_pretrained_model(repo_id, speed)
|
85 |
|
86 |
start = time.time()
|
87 |
+
audio = tts.generate(text, sid=sid)
|
88 |
end = time.time()
|
89 |
|
90 |
if len(audio.samples) == 0:
|
|
|
104 |
"""
|
105 |
|
106 |
logging.info(info)
|
107 |
+
logging.info(f"\nrepo_id: {repo_id}\ntext: {text}\nsid: {sid}\nspeed: {speed}")
|
108 |
|
109 |
filename = str(uuid.uuid4())
|
110 |
filename = f"{filename}.wav"
|
|
|
123 |
|
124 |
with demo:
|
125 |
gr.Markdown(title)
|
126 |
+
language_choices = list(language_to_models.keys())
|
127 |
+
|
128 |
+
language_radio = gr.Radio(
|
129 |
+
label="Idioma",
|
130 |
+
choices=language_choices,
|
131 |
+
value=language_choices[0],
|
132 |
+
)
|
133 |
+
|
134 |
+
model_dropdown = gr.Dropdown(
|
135 |
+
choices=language_to_models[language_choices[0]],
|
136 |
+
label="Seleccion un modelo",
|
137 |
+
value=language_to_models[language_choices[0]][0],
|
138 |
+
)
|
139 |
+
|
140 |
+
language_radio.change(
|
141 |
+
update_model_dropdown,
|
142 |
+
inputs=language_radio,
|
143 |
+
outputs=model_dropdown,
|
144 |
+
)
|
145 |
|
146 |
with gr.Tabs():
|
147 |
with gr.TabItem("Por favor ingresa tu texto"):
|
|
|
152 |
placeholder="Por favor ingresa tu texto aquí",
|
153 |
)
|
154 |
|
155 |
+
input_sid = gr.Textbox(
|
156 |
+
label="Speaker ID",
|
157 |
+
info="Speaker ID",
|
158 |
+
lines=1,
|
159 |
+
max_lines=1,
|
160 |
+
value="0",
|
161 |
+
placeholder="Speaker ID. Valid only for mult-speaker model",
|
162 |
+
)
|
163 |
+
print(input_sid)
|
164 |
+
|
165 |
input_speed = gr.Slider(
|
166 |
minimum=0.1,
|
167 |
maximum=10,
|
|
|
179 |
input_button.click(
|
180 |
process,
|
181 |
inputs=[
|
182 |
+
language_radio,
|
183 |
+
model_dropdown,
|
184 |
input_text,
|
185 |
+
input_sid,
|
186 |
input_speed,
|
187 |
],
|
188 |
outputs=[
|