Spaces:
Build error
Build error
File size: 1,645 Bytes
118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 902212c 118dfb0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | import gradio as gr
from app.pipeline import FullEgyptianVoiceChatbot
bot = FullEgyptianVoiceChatbot()
def text_chat(text):
r = bot.chat_text(text)
return r["user_text"], r["user_normalized"], r["assistant_text_raw"], r["assistant_text_tts"], r["audio_path"]
def voice_chat(audio_fp):
r = bot.chat_voice(audio_fp)
if "error" in r:
return "", "", r["error"], "", None
return r["user_text"], r["user_normalized"], r["assistant_text_raw"], r["assistant_text_tts"], r["audio_path"]
with gr.Blocks() as demo:
gr.Markdown("Egyptian Arabic Voice Chatbot (Whisper ASR + JAIS + EGTTS)")
with gr.Tab("Text"):
inp = gr.Textbox(label="Input (Egyptian Arabic)")
o_user = gr.Textbox(label="User Text")
o_norm = gr.Textbox(label="Normalized")
o_raw = gr.Textbox(label="JAIS Raw Response")
o_tts = gr.Textbox(label="TTS-ready Response")
o_aud = gr.Audio(label="Bot Audio", type="filepath")
btn = gr.Button("Send")
btn.click(text_chat, inputs=inp, outputs=[o_user, o_norm, o_raw, o_tts, o_aud])
with gr.Tab("Voice"):
v_in = gr.Audio(sources=["microphone","upload"], type="filepath", label="Record / Upload")
v_user = gr.Textbox(label="User Text (ASR)")
v_norm = gr.Textbox(label="Normalized")
v_raw = gr.Textbox(label="JAIS Raw Response")
v_tts = gr.Textbox(label="TTS-ready Response")
v_out = gr.Audio(label="Bot Audio", type="filepath")
v_btn = gr.Button("Send Voice")
v_btn.click(voice_chat, inputs=v_in, outputs=[v_user, v_norm, v_raw, v_tts, v_out])
demo.queue()
demo.launch() |