omersaidd commited on
Commit
0349429
·
verified ·
1 Parent(s): a6bfb72

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import SpeechRecognition as sr
3
+
4
+ def recognize_audio(file_path):
5
+ # initialize the recognizer
6
+ r = sr.Recognizer()
7
+
8
+ # open the file
9
+ with sr.AudioFile(file_path) as source:
10
+ # listen for the data (load audio to memory)
11
+ audio_data = r.record(source)
12
+ # recognize (convert from speech to text) with Turkish language support
13
+ text = r.recognize_google(audio_data, language="tr-TR")
14
+ return text
15
+
16
+ def save_to_file(text, file_path):
17
+ with open(file_path, "w", encoding="utf-8") as file:
18
+ file.write(text)
19
+
20
+ def main():
21
+ st.title("Sesden Metine Çevirme Uygulaması")
22
+
23
+ uploaded_file = st.file_uploader("Dosya Ekleme", type=["wav", "mp3"])
24
+
25
+ if uploaded_file:
26
+ result = recognize_audio(uploaded_file)
27
+ st.subheader("Çevirilen Metin:")
28
+ st.write(result)
29
+
30
+ # Save the recognized text to a text file
31
+ save_to_file(result, "kayıt_text.txt")
32
+ st.success("Tanınan metin başarıyla bir dosyaya kaydedildi: kayıt_text.txt")
33
+
34
+ if __name__ == "__main__":
35
+ main()