Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,34 +13,33 @@ lang_options = {
|
|
| 13 |
}
|
| 14 |
|
| 15 |
# Dil seçimi
|
| 16 |
-
input_language=st.selectbox("
|
| 17 |
lang_input=lang_options[input_language]
|
| 18 |
-
selected_lang = st.selectbox("
|
| 19 |
lang = lang_options[selected_lang]
|
| 20 |
|
| 21 |
-
uploaded_file = st.file_uploader("
|
| 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"
|
| 27 |
|
| 28 |
-
|
| 29 |
-
if st.button("
|
| 30 |
try:
|
| 31 |
-
|
| 32 |
-
output_filename =
|
| 33 |
-
|
| 34 |
-
st.success(f"
|
| 35 |
|
| 36 |
-
|
| 37 |
with open(output_filename, "rb") as file:
|
| 38 |
st.download_button(
|
| 39 |
-
label="
|
| 40 |
data=file,
|
| 41 |
file_name=output_filename,
|
| 42 |
mime="audio/mpeg",
|
| 43 |
)
|
| 44 |
except Exception as e:
|
| 45 |
-
st.error("
|
| 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)
|