Spaces:
Build error
Build error
File size: 1,386 Bytes
0349429 5998c6c 1d01fc9 33fd4ed 0349429 33fd4ed 0349429 33fd4ed 0349429 33fd4ed 0349429 1d01fc9 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
import streamlit as st
import speech_recognition as sr
def recognize_speech(duration):
# initialize the recognizer
r = sr.Recognizer()
st.info("Lütfen konuşun")
with sr.Microphone() as source:
st.warning("Kaydediliyor...")
# read the audio data from the default microphone
audio_data = r.record(source, duration=duration)
st.success("Kayıt Tamamlandı!")
st.subheader("Tanınan Metin:")
# convert speech to text with Turkish language support
try:
text = r.recognize_google(audio_data, language="tr-TR")
st.write(text)
# Save the recognized text to a text file
save_to_file(text, "recognized_text.txt")
st.success("Tanınan metin başarıyla bir dosyaya kaydedildi: recognized_text.txt")
except sr.UnknownValueError:
st.error("Konuşma Anlaşılamadı")
except sr.RequestError as e:
st.error(f"Hata Oluştu: {e}")
def save_to_file(text, file_path):
with open(file_path, "w", encoding="utf-8") as file:
file.write(text)
def main():
st.title("Canlı Kayıdı Metine Dönüştürme")
duration = st.slider("Kayıt Süresi (saniye)", min_value=1, max_value=60, value=3, step=1)
if st.button("Başla"):
recognize_speech(duration)
if __name__ == "__main__":
main()
|