Spaces:
Sleeping
Sleeping
app.py
Browse files🔊 Speech To Text (Speech to Text) Application! 🔍📄
Hello Everyone!
🚀 I'm excited to share with you my Streamlit-based application that I developed for easily converting your voice notes or audio files into text. 🎙️✨
Application Features:
🎤🔗 Option to record live audio or upload audio files
🗣️🇹🇷 Powerful speech recognition algorithm with support for the Turkish language
📝💾 Ability to save results to a text file
Click the "Start" button for live audio recording or upload an audio file.
Once the recognition process is complete, the text results will be displayed below the screen.
And in the background, it is saved in .txt format.
app.py
ADDED
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import speech_recognition as sr
|
3 |
+
|
4 |
+
def recognize_speech(duration):
|
5 |
+
# initialize the recognizer
|
6 |
+
r = sr.Recognizer()
|
7 |
+
|
8 |
+
st.info("Lütfen konuşun")
|
9 |
+
|
10 |
+
with sr.Microphone() as source:
|
11 |
+
st.warning("Kaydediliyor...")
|
12 |
+
# read the audio data from the default microphone
|
13 |
+
audio_data = r.record(source, duration=duration)
|
14 |
+
st.success("Kayıt Tamamlandı!")
|
15 |
+
|
16 |
+
st.subheader("Tanınan Metin:")
|
17 |
+
# convert speech to text with Turkish language support
|
18 |
+
try:
|
19 |
+
text = r.recognize_google(audio_data, language="tr-TR")
|
20 |
+
st.write(text)
|
21 |
+
|
22 |
+
# Save the recognized text to a text file
|
23 |
+
save_to_file(text, "recognized_text.txt")
|
24 |
+
st.success("Tanınan metin başarıyla bir dosyaya kaydedildi: recognized_text.txt")
|
25 |
+
except sr.UnknownValueError:
|
26 |
+
st.error("Konuşma Anlaşılamadı")
|
27 |
+
except sr.RequestError as e:
|
28 |
+
st.error(f"Hata Oluştu: {e}")
|
29 |
+
|
30 |
+
def save_to_file(text, file_path):
|
31 |
+
with open(file_path, "w", encoding="utf-8") as file:
|
32 |
+
file.write(text)
|
33 |
+
|
34 |
+
def main():
|
35 |
+
st.title("Canlı Kayıdı Metine Dönüştürme")
|
36 |
+
|
37 |
+
duration = st.slider("Kayıt Süresi (saniye)", min_value=1, max_value=60, value=3, step=1)
|
38 |
+
|
39 |
+
if st.button("Başla"):
|
40 |
+
recognize_speech(duration)
|
41 |
+
|
42 |
+
if __name__ == "__main__":
|
43 |
+
main()
|