# voice_component.py
import streamlit as st
import streamlit.components.v1 as components
def voice_input_component():
"""
Creates a voice input component that uses the browser's Web Speech API.
Returns the transcribed text from voice input.
"""
# HTML component for voice input
voice_html = """
"""
# Generate a unique key for the component
key = "voice_input"
# Initialize session state for voice input if not exists
if key not in st.session_state:
st.session_state[key] = ""
# Render the component
components.html(voice_html, height=200)
# Return the last transcript
return st.session_state.get(key, "")