Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -70,6 +70,7 @@ if st.button("Submit"):
|
|
70 |
inputs = tokenizer(text_input, return_tensors="pt")
|
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.")
|
@@ -94,7 +95,7 @@ if st.button("Reset"):
|
|
94 |
st.experimental_rerun() # Reload the app to reset the inputs
|
95 |
|
96 |
# Display current state of translated text and audio
|
97 |
-
if st.session_state.translated_text:
|
98 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
99 |
-
|
100 |
-
st.audio(st.session_state.audio_path, format="audio/wav")
|
|
|
70 |
inputs = tokenizer(text_input, return_tensors="pt")
|
71 |
translated = model.generate(**inputs)
|
72 |
st.session_state.translated_text = tokenizer.decode(translated[0], skip_special_tokens=True)
|
73 |
+
st.session_state.audio_path = "" # Clear previous audio path
|
74 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
75 |
else:
|
76 |
st.error("Please enter text and select a target language.")
|
|
|
95 |
st.experimental_rerun() # Reload the app to reset the inputs
|
96 |
|
97 |
# Display current state of translated text and audio
|
98 |
+
if st.session_state.translated_text and not st.session_state.audio_path:
|
99 |
st.write(f"Translated text: {st.session_state.translated_text}")
|
100 |
+
elif st.session_state.audio_path:
|
101 |
+
st.audio(st.session_state.audio_path, format="audio/wav")
|