sylaork commited on
Commit
8c01a2f
·
verified ·
1 Parent(s): 912daa2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -14
app.py CHANGED
@@ -13,34 +13,33 @@ lang_options = {
13
  }
14
 
15
  # Dil seçimi
16
- input_language=st.selectbox("Lütfen metin dilini seçiniz", list(lang_options.keys()))
17
  lang_input=lang_options[input_language]
18
- selected_lang = st.selectbox("Lütfen ses dili seçiniz", list(lang_options.keys()))
19
  lang = lang_options[selected_lang]
20
 
21
- uploaded_file = st.file_uploader("Lütfen bir .txt dosyası yükleyiniz:", type=["txt"])
22
 
23
  if uploaded_file is not None:
24
- # Dosya içeriğini oku
25
  text = uploaded_file.read().decode('utf-8')
26
- st.write(f"Yüklenen dosyanın içeriği:\n{text}")
27
 
28
- # Ses dosyasını oluştur
29
- if st.button("Sesi Oluştur"):
30
  try:
31
- tts = gTTS(text=text, lang=lang, slow=False)
32
- output_filename = os.path.splitext(uploaded_file.name)[0] + '.mp3'
33
- tts.save(output_filename)
34
- st.success(f"Ses dosyası oluşturuldu: {output_filename}")
35
 
36
- # Ses dosyasını indir
37
  with open(output_filename, "rb") as file:
38
  st.download_button(
39
- label="Ses Dosyasını İndir",
40
  data=file,
41
  file_name=output_filename,
42
  mime="audio/mpeg",
43
  )
44
  except Exception as e:
45
- st.error("Ses dosyası oluşturulamadı.")
46
  print("Hata:", e)
 
13
  }
14
 
15
  # Dil seçimi
16
+ input_language=st.selectbox("Your txt language:", list(lang_options.keys()))
17
  lang_input=lang_options[input_language]
18
+ selected_lang = st.selectbox("Language to be vocalized:", list(lang_options.keys()))
19
  lang = lang_options[selected_lang]
20
 
21
+ uploaded_file = st.file_uploader("Upload.txt file:", type=["txt"])
22
 
23
  if uploaded_file is not None:
 
24
  text = uploaded_file.read().decode('utf-8')
25
+ st.write(f"Text:\n{text}")
26
 
27
+
28
+ if st.button("Create"):
29
  try:
30
+ save_it = gTTS(text=text, lang=lang, slow=False)
31
+ output_filename = str(text[:5]) + '.mp3'
32
+ save_it.save(output_filename)
33
+ st.success(f"Here is your file: {output_filename}")
34
 
35
+
36
  with open(output_filename, "rb") as file:
37
  st.download_button(
38
+ label="Download",
39
  data=file,
40
  file_name=output_filename,
41
  mime="audio/mpeg",
42
  )
43
  except Exception as e:
44
+ st.error("Error.")
45
  print("Hata:", e)