Update app.py
Browse files
app.py
CHANGED
@@ -18,7 +18,7 @@ import threading
|
|
18 |
|
19 |
# --- Login to Hugging Face using secret ---
|
20 |
# Make sure HF_TOKEN is set in your Hugging Face Space > Settings > Repository secrets
|
21 |
-
hf_token = os.environ.get("hugface")
|
22 |
if not hf_token:
|
23 |
raise ValueError("HF_TOKEN not found. Please set it in Hugging Face Space repository secrets.")
|
24 |
login(token=hf_token)
|
@@ -221,4 +221,52 @@ with gr.Blocks(theme=gr.themes.Soft(), title="Msaidizi wa Kiswahili") as demo:
|
|
221 |
gr.Markdown("### Utengenezaji wa Sauti (Speech Synthesis)")
|
222 |
tool_t2s_text_in = gr.Textbox(label="Maandishi ya Kuingiza (Input Text)", placeholder="Andika Kiswahili hapa...")
|
223 |
tool_t2s_audio_out = gr.Audio(type="filepath", label="Sauti Iliyotengenezwa (Synthesized Audio)", autoplay=False)
|
224 |
-
tool_t2s_btn = gr.Button("Tengeneza Sauti
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
# --- Login to Hugging Face using secret ---
|
20 |
# Make sure HF_TOKEN is set in your Hugging Face Space > Settings > Repository secrets
|
21 |
+
hf_token = os.environ.get("hugface") # Using "HF_TOKEN" is the standard on Spaces
|
22 |
if not hf_token:
|
23 |
raise ValueError("HF_TOKEN not found. Please set it in Hugging Face Space repository secrets.")
|
24 |
login(token=hf_token)
|
|
|
221 |
gr.Markdown("### Utengenezaji wa Sauti (Speech Synthesis)")
|
222 |
tool_t2s_text_in = gr.Textbox(label="Maandishi ya Kuingiza (Input Text)", placeholder="Andika Kiswahili hapa...")
|
223 |
tool_t2s_audio_out = gr.Audio(type="filepath", label="Sauti Iliyotengenezwa (Synthesized Audio)", autoplay=False)
|
224 |
+
tool_t2s_btn = gr.Button("Tengeneza Sauti (Synthesize)")
|
225 |
+
|
226 |
+
s2s_submit_btn.click(
|
227 |
+
fn=s2s_pipeline,
|
228 |
+
inputs=[s2s_audio_in, s2s_chatbot],
|
229 |
+
outputs=[s2s_chatbot, s2s_audio_out, s2s_text_out],
|
230 |
+
queue=True
|
231 |
+
).then(
|
232 |
+
fn=lambda: gr.Audio(value=None),
|
233 |
+
inputs=None,
|
234 |
+
outputs=s2s_audio_in
|
235 |
+
)
|
236 |
+
|
237 |
+
t2t_submit_btn.click(
|
238 |
+
fn=t2t_pipeline,
|
239 |
+
inputs=[t2t_text_in, t2t_chatbot],
|
240 |
+
outputs=[t2t_chatbot],
|
241 |
+
queue=True
|
242 |
+
).then(
|
243 |
+
fn=clear_textbox,
|
244 |
+
inputs=None,
|
245 |
+
outputs=t2t_text_in
|
246 |
+
)
|
247 |
+
|
248 |
+
t2t_text_in.submit(
|
249 |
+
fn=t2t_pipeline,
|
250 |
+
inputs=[t2t_text_in, t2t_chatbot],
|
251 |
+
outputs=[t2t_chatbot],
|
252 |
+
queue=True
|
253 |
+
).then(
|
254 |
+
fn=clear_textbox,
|
255 |
+
inputs=None,
|
256 |
+
outputs=t2t_text_in
|
257 |
+
)
|
258 |
+
|
259 |
+
tool_s2t_btn.click(
|
260 |
+
fn=assistant.transcribe_audio,
|
261 |
+
inputs=tool_s2t_audio_in,
|
262 |
+
outputs=tool_s2t_text_out,
|
263 |
+
queue=True
|
264 |
+
)
|
265 |
+
tool_t2s_btn.click(
|
266 |
+
fn=assistant.generate_speech,
|
267 |
+
inputs=tool_t2s_text_in,
|
268 |
+
outputs=tool_t2s_audio_out,
|
269 |
+
queue=True
|
270 |
+
)
|
271 |
+
|
272 |
+
demo.queue().launch(debug=True)
|