Spaces:
Build error
Build error
Download app.py from SherinMohamed/Egyptian_Chatbot: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/spaces/SherinMohamed/Egyptian_Chatbot/resolve/main/app.py
- Command line
-
hf download hf://spaces/SherinMohamed/Egyptian_Chatbot/app.py
-
curl -L -o app.py https://huggingface.co/spaces/SherinMohamed/Egyptian_Chatbot/resolve/main/app.py
1.65 kB
| 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() |