Update app.py
Browse files
app.py
CHANGED
|
@@ -62,26 +62,44 @@ if uploaded_video is not None:
|
|
| 62 |
with tempfile.NamedTemporaryFile(delete=False) as tmp_video:
|
| 63 |
tmp_video.write(uploaded_video.read())
|
| 64 |
tmp_video_path = tmp_video.name
|
| 65 |
-
|
| 66 |
-
#
|
| 67 |
-
st.
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
with tempfile.NamedTemporaryFile(delete=False) as tmp_video:
|
| 63 |
tmp_video.write(uploaded_video.read())
|
| 64 |
tmp_video_path = tmp_video.name
|
| 65 |
+
|
| 66 |
+
# Add an "Analyze Video" button
|
| 67 |
+
if st.button("Analyze Video"):
|
| 68 |
+
with st.spinner("Processing video... Please wait."):
|
| 69 |
+
# Convert video to audio
|
| 70 |
+
audio_file = video_to_audio(tmp_video_path)
|
| 71 |
+
|
| 72 |
+
# Convert the extracted MP3 audio to WAV
|
| 73 |
+
wav_audio_file = convert_mp3_to_wav(audio_file)
|
| 74 |
+
|
| 75 |
+
# Transcribe audio to text
|
| 76 |
+
transcription = transcribe_audio(wav_audio_file)
|
| 77 |
+
|
| 78 |
+
# Show the transcription
|
| 79 |
+
st.text_area("Transcription", transcription, height=300)
|
| 80 |
+
|
| 81 |
+
# Provide the audio file to the user for download
|
| 82 |
+
st.audio(wav_audio_file, format="audio/wav")
|
| 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 |
+
os.remove(wav_audio_file)
|