AmirFARES commited on
Commit
b44d107
ยท
1 Parent(s): 5d86b52

removed upload option, not working properly on hf space

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -25
src/streamlit_app.py CHANGED
@@ -1,5 +1,4 @@
1
  import streamlit as st
2
- import os
3
  from downloader import download_video
4
  from extractor import extract_audio
5
  from detector import detect_accent
@@ -7,41 +6,27 @@ from detector import detect_accent
7
  st.set_page_config(page_title="Accent Detector", page_icon="๐ŸŽ™๏ธ")
8
 
9
  st.title("๐ŸŽ™๏ธ English Accent Classifier")
10
- st.write("Paste a public Loom or MP4 link OR upload a video file to get an English accent classification.")
11
 
12
- # Input options:
13
  video_url = st.text_input("Video URL (MP4 or Loom):")
14
- uploaded_file = st.file_uploader("Or upload a video file (MP4)", type=["mp4"])
15
 
16
  # When user clicks Analyze
17
  if st.button("Analyze"):
18
 
19
- # Validate input
20
- if not video_url and not uploaded_file:
21
- st.error("Please provide a video URL or upload a video file.")
22
  else:
23
  try:
24
- # Step 1: get the video file path for extractor
25
-
26
- if uploaded_file is not None:
27
- # uploaded_file is BytesIO-like object
28
- # We need to save it to a temporary file path for extract_audio()
29
- import tempfile
30
-
31
- with tempfile.NamedTemporaryFile(suffix=".mp4", delete=False) as tmp:
32
- tmp.write(uploaded_file.read())
33
- video_file_path = tmp.name
34
-
35
- else:
36
- # Download video from URL to local file path (your existing function)
37
- with st.spinner("Downloading video..."):
38
- video_file_path = download_video(video_url)
39
-
40
- # Step 2: extract audio
41
  with st.spinner("Extracting audio..."):
42
  audio_file = extract_audio(video_file_path)
43
 
44
- # Step 3: detect accent
45
  with st.spinner("Transcribing & detecting accent..."):
46
  accent, confidence, transcript = detect_accent(audio_file)
47
 
 
1
  import streamlit as st
 
2
  from downloader import download_video
3
  from extractor import extract_audio
4
  from detector import detect_accent
 
6
  st.set_page_config(page_title="Accent Detector", page_icon="๐ŸŽ™๏ธ")
7
 
8
  st.title("๐ŸŽ™๏ธ English Accent Classifier")
9
+ st.write("Paste a public Loom or MP4 link to get an English accent classification.")
10
 
11
+ # Input option (URL only)
12
  video_url = st.text_input("Video URL (MP4 or Loom):")
 
13
 
14
  # When user clicks Analyze
15
  if st.button("Analyze"):
16
 
17
+ if not video_url:
18
+ st.error("Please provide a video URL.")
 
19
  else:
20
  try:
21
+ # Step 1: Download video
22
+ with st.spinner("Downloading video..."):
23
+ video_file_path = download_video(video_url)
24
+
25
+ # Step 2: Extract audio
 
 
 
 
 
 
 
 
 
 
 
 
26
  with st.spinner("Extracting audio..."):
27
  audio_file = extract_audio(video_file_path)
28
 
29
+ # Step 3: Detect accent
30
  with st.spinner("Transcribing & detecting accent..."):
31
  accent, confidence, transcript = detect_accent(audio_file)
32