', unsafe_allow_html=True) # Demo sentences DEMO_SENTENCES = [ "Please clean", "Come here", "Hello", "I appreciate you", "Announce the answer", "Arrive and attend", "Ask anyone", "Around the apartment", ] st.markdown('
Quick Demo
', unsafe_allow_html=True) st.markdown('
Try a sentence
', unsafe_allow_html=True) # Demo pills as buttons cols = st.columns(4) selected_demo = None for idx, sentence in enumerate(DEMO_SENTENCES): with cols[idx % 4]: if st.button(sentence, key=f"demo_{idx}"): selected_demo = sentence st.markdown("
", unsafe_allow_html=True) # Input tabs st.markdown('
Translate
', unsafe_allow_html=True) tab1, tab2 = st.tabs(["๐Ÿ“ Text Input", "๐ŸŽ™๏ธ Audio Upload"]) transcript = "" mode = "" with tab1: default_text = selected_demo if selected_demo else "" txt = st.text_area( "Enter English text", value=default_text, placeholder="Type anything โ€” e.g. 'Please come here'", height=100, label_visibility="collapsed" ) if st.button("๐ŸคŸ Translate to ASL", key="text_btn") and txt: transcript = txt mode = "Text" with tab2: upload = st.file_uploader( "Upload audio (WAV/MP3)", type=["wav", "mp3"], label_visibility="collapsed" ) if upload and st.button("๐ŸŽ™๏ธ Transcribe + Translate", key="audio_btn"): tmp = "temp_input.wav" with open(tmp, "wb") as f: f.write(upload.getbuffer()) with st.spinner("Transcribing with Whisper..."): try: transcript = transcribe_file(tmp) mode = "Audio" except Exception as e: st.error(f"Transcription failed: {e}") finally: if os.path.exists(tmp): os.remove(tmp) if selected_demo and not transcript: transcript = selected_demo mode = "Text" # โ”€โ”€ PIPELINE โ”€โ”€ if transcript: st.markdown("
", unsafe_allow_html=True) with st.status("โšก Running SignLink Pipeline...", expanded=True) as status: st.write("๐Ÿง  Generating ASL gloss tokens...") gloss = build_gloss_sequence(transcript, "gemma3n_E2B") st.write("๐Ÿ—‚๏ธ Retrieving motion capture assets...") dictionary = ASLDictionary() paths = dictionary.get_paths(gloss) status.update(label="โœ… Translation Complete", state="complete", expanded=False) if paths: try: out_video = stitch_clips(paths) st.video(out_video) except Exception as e: st.error(f"Video rendering error: {e}") # Results card tags_html = "".join([f"{t}" for t in gloss]) st.markdown(f"""
Original Input
"{transcript}"
ASL Gloss Tokens
{tags_html}
โœ“ {len(paths)} clips assembled  ยท  Gemma โ†’ Lemmatization โ†’ Fingerspelling fallback
""", unsafe_allow_html=True) else: st.warning("No ASL clips found for this input.") st.markdown('