Update app.py
Browse files
app.py
CHANGED
@@ -39,31 +39,34 @@ if st.button("Analyze new video"):
|
|
39 |
# Check for ffmpeg
|
40 |
if not shutil.which("ffmpeg"):
|
41 |
raise EnvironmentError("FFmpeg not found. Please install or add it to PATH.")
|
|
|
42 |
|
|
|
43 |
# Input options
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
elif option == "Enter Video Url":
|
58 |
-
yt_url = st.text_input("Paste YouTube URL")
|
59 |
-
if st.button("Download Video"):
|
60 |
-
with st.spinner("Downloading video..."):
|
61 |
-
audio_path = download_audio_as_wav(yt_url)
|
62 |
-
audio_path = trim_audio(audio_path)
|
63 |
-
if audio_path:
|
64 |
-
st.success("Video downloaded successfully.")
|
65 |
st.session_state.audio_path = audio_path
|
66 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
# Transcription and Accent Analysis
|
69 |
if st.session_state.audio_path and not st.session_state.transcription:
|
|
|
39 |
# Check for ffmpeg
|
40 |
if not shutil.which("ffmpeg"):
|
41 |
raise EnvironmentError("FFmpeg not found. Please install or add it to PATH.")
|
42 |
+
|
43 |
|
44 |
+
|
45 |
# Input options
|
46 |
+
if "audio_path" not in st.session_state:
|
47 |
+
option = st.radio("Choose input method:", ["Upload video file", "Enter Video Url"])
|
48 |
+
|
49 |
+
if option == "Upload video file":
|
50 |
+
uploaded_video = st.file_uploader("Upload your video", type=["mp4", "mov", "avi", "mkv"])
|
51 |
+
if uploaded_video is not None:
|
52 |
+
temp_video_path = tempfile.NamedTemporaryFile(delete=False, suffix=".mp4")
|
53 |
+
with open(temp_video_path.name, "wb") as f:
|
54 |
+
f.write(uploaded_video.read())
|
55 |
+
audio_path = trim_video(temp_video_path.name)
|
56 |
+
st.success("Video uploaded successfully.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
st.session_state.audio_path = audio_path
|
58 |
|
59 |
+
|
60 |
+
elif option == "Enter Video Url":
|
61 |
+
yt_url = st.text_input("Paste YouTube URL")
|
62 |
+
if st.button("Download Video"):
|
63 |
+
with st.spinner("Downloading video..."):
|
64 |
+
audio_path = download_audio_as_wav(yt_url)
|
65 |
+
audio_path = trim_audio(audio_path)
|
66 |
+
if audio_path:
|
67 |
+
st.success("Video downloaded successfully.")
|
68 |
+
st.session_state.audio_path = audio_path
|
69 |
+
|
70 |
|
71 |
# Transcription and Accent Analysis
|
72 |
if st.session_state.audio_path and not st.session_state.transcription:
|