real time stt microphone
To upload files, please first save the app
import streamlit as st
import speech_recognition as sr
st.title('Real Time Speech to Text (STT) using Microphone')
# Initialize the recognizer
recognizer = sr.Recognizer()
st.write('Press the button below to start recording your voice.')
if st.button('Start Recording'):
with sr.Microphone() as source:
st.write('Listening...')
audio = recognizer.listen(source)
st.write('Recording stopped.')
# Perform speech recognition on the recorded audio
try:
text = recognizer.recognize_google(audio)
st.write('Transcript:')
st.success(text)
except sr.UnknownValueError:
st.error("Google Speech Recognition could not understand audio")
except sr.RequestError as e:
st.error(f"Could not request results from Google Speech Recognition service; {e}")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?