Update app.py
Browse files
app.py
CHANGED
|
@@ -78,28 +78,33 @@ if uploaded_video is not None:
|
|
| 78 |
# Show the transcription
|
| 79 |
st.text_area("Transcription", transcription, height=300)
|
| 80 |
|
| 81 |
-
#
|
| 82 |
-
st.
|
| 83 |
-
|
| 84 |
-
# Add download buttons for the transcription and audio
|
| 85 |
-
# Downloadable transcription file
|
| 86 |
-
st.download_button(
|
| 87 |
-
label="Download Transcription",
|
| 88 |
-
data=transcription,
|
| 89 |
-
file_name="transcription.txt",
|
| 90 |
-
mime="text/plain"
|
| 91 |
-
)
|
| 92 |
-
|
| 93 |
-
# Downloadable audio file
|
| 94 |
-
with open(wav_audio_file, "rb") as audio_file_data:
|
| 95 |
-
st.download_button(
|
| 96 |
-
label="Download Audio",
|
| 97 |
-
data=audio_file_data,
|
| 98 |
-
file_name="converted_audio.wav",
|
| 99 |
-
mime="audio/wav"
|
| 100 |
-
)
|
| 101 |
|
| 102 |
# Cleanup temporary files
|
| 103 |
os.remove(tmp_video_path)
|
| 104 |
os.remove(audio_file)
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
# Show the transcription
|
| 79 |
st.text_area("Transcription", transcription, height=300)
|
| 80 |
|
| 81 |
+
# Store transcription and audio file in session state
|
| 82 |
+
st.session_state.transcription = transcription
|
| 83 |
+
st.session_state.wav_audio_file = wav_audio_file
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
# Cleanup temporary files
|
| 86 |
os.remove(tmp_video_path)
|
| 87 |
os.remove(audio_file)
|
| 88 |
+
|
| 89 |
+
# Check if transcription and audio file are stored in session state
|
| 90 |
+
if 'transcription' in st.session_state and 'wav_audio_file' in st.session_state:
|
| 91 |
+
# Provide the audio file to the user for download
|
| 92 |
+
st.audio(st.session_state.wav_audio_file, format='audio/wav')
|
| 93 |
+
|
| 94 |
+
# Add download buttons for the transcription and audio
|
| 95 |
+
# Downloadable transcription file
|
| 96 |
+
st.download_button(
|
| 97 |
+
label="Download Transcription",
|
| 98 |
+
data=st.session_state.transcription,
|
| 99 |
+
file_name="transcription.txt",
|
| 100 |
+
mime="text/plain"
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
# Downloadable audio file
|
| 104 |
+
with open(st.session_state.wav_audio_file, "rb") as audio_file_data:
|
| 105 |
+
st.download_button(
|
| 106 |
+
label="Download Audio",
|
| 107 |
+
data=audio_file_data,
|
| 108 |
+
file_name="converted_audio.wav",
|
| 109 |
+
mime="audio/wav"
|
| 110 |
+
)
|