Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -71,6 +71,8 @@ if st.button("Submit"):
|
|
71 |
translated = model.generate(**inputs)
|
72 |
st.session_state.translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
73 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
|
|
|
|
74 |
|
75 |
# Listen to Translated Audio button
|
76 |
if st.button("Listen to Translated Audio"):
|
@@ -87,6 +89,8 @@ if st.button("Listen to Translated Audio"):
|
|
87 |
if st.button("Reset"):
|
88 |
st.session_state.translated_text = ""
|
89 |
st.session_state.audio_path = ""
|
|
|
|
|
90 |
st.experimental_rerun() # Reload the app to reset the inputs
|
91 |
|
92 |
# Display current state of translated text and audio
|
@@ -94,5 +98,3 @@ if st.session_state.translated_text:
|
|
94 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
95 |
if st.session_state.audio_path:
|
96 |
st.audio(st.session_state.audio_path, format="audio/wav")
|
97 |
-
|
98 |
-
|
|
|
71 |
translated = model.generate(**inputs)
|
72 |
st.session_state.translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
73 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
74 |
+
else:
|
75 |
+
st.error("Please enter text and select a target language.")
|
76 |
|
77 |
# Listen to Translated Audio button
|
78 |
if st.button("Listen to Translated Audio"):
|
|
|
89 |
if st.button("Reset"):
|
90 |
st.session_state.translated_text = ""
|
91 |
st.session_state.audio_path = ""
|
92 |
+
st.text_area("Enter text in English", value="", key="text_input")
|
93 |
+
st.selectbox("Select target language", ["fr", "zh", "it", "ur", "hi"], key="target_lang")
|
94 |
st.experimental_rerun() # Reload the app to reset the inputs
|
95 |
|
96 |
# Display current state of translated text and audio
|
|
|
98 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
99 |
if st.session_state.audio_path:
|
100 |
st.audio(st.session_state.audio_path, format="audio/wav")
|
|
|
|