Spaces:
Sleeping
Sleeping
removed upload option, not working properly on hf space
Browse files- 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
|
| 11 |
|
| 12 |
-
# Input
|
| 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 |
-
|
| 20 |
-
|
| 21 |
-
st.error("Please provide a video URL or upload a video file.")
|
| 22 |
else:
|
| 23 |
try:
|
| 24 |
-
# Step 1:
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 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:
|
| 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 |
|