Spaces:
Build error
Build error
File size: 1,055 Bytes
58d9c50 e53c421 58d9c50 e53c421 58d9c50 e53c421 58d9c50 6faa2c8 e53c421 58d9c50 |
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 |
import streamlit as st
import speech_recognition as sr
def main():
st.title("Speech to Text - Open Source")
# Instructions
st.write("Click the button below to start recording your voice.")
# Button to start recording
if st.button("Start Recording"):
recognizer = sr.Recognizer()
try:
with sr.Microphone() as source:
st.write("Listening... Please speak clearly.")
audio = recognizer.listen(source, timeout=5, phrase_time_limit=10)
st.write("Processing the audio...")
text = recognizer.recognize_google(audio, language='fa-IR') # Change language if needed
st.write(f"Recognized Text: {text}")
except sr.UnknownValueError:
st.write("Could not understand the audio.")
except sr.RequestError:
st.write("Error: Unable to connect to the speech recognition service.")
except Exception as e:
st.write(f"An error occurred: {str(e)}")
if __name__ == '__main__':
main()
|