Spaces:
Running
Running
removed youtube dlp
Browse files
app.py
CHANGED
@@ -6,7 +6,6 @@ import requests
|
|
6 |
from moviepy import VideoFileClip
|
7 |
from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration, Wav2Vec2Processor, Wav2Vec2Model
|
8 |
import torchaudio
|
9 |
-
import yt_dlp as youtube_dl
|
10 |
|
11 |
# Load Whisper model to confirm English
|
12 |
whisper_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-tiny", device="cpu")
|
@@ -22,25 +21,13 @@ def classify_accent(audio_tensor, sample_rate):
|
|
22 |
}
|
23 |
|
24 |
def download_video(url):
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
34 |
-
info = ydl.extract_info(url, download=True)
|
35 |
-
return ydl.prepare_filename(info)
|
36 |
-
else:
|
37 |
-
video_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
|
38 |
-
response = requests.get(url, stream=True)
|
39 |
-
with open(video_path, "wb") as f:
|
40 |
-
for chunk in response.iter_content(chunk_size=1024*1024):
|
41 |
-
if chunk:
|
42 |
-
f.write(chunk)
|
43 |
-
return video_path
|
44 |
|
45 |
def extract_audio(video_path):
|
46 |
audio_path = tempfile.NamedTemporaryFile(suffix=".wav", delete=False).name
|
@@ -83,8 +70,8 @@ def analyze_accent(url):
|
|
83 |
|
84 |
gr.Interface(
|
85 |
fn=analyze_accent,
|
86 |
-
inputs=gr.Textbox(label="Public Video URL (e.g. MP4
|
87 |
outputs=gr.Markdown(label="Accent Analysis Result"),
|
88 |
title="English Accent Classifier",
|
89 |
-
description="Paste a video URL (MP4
|
90 |
).launch()
|
|
|
6 |
from moviepy import VideoFileClip
|
7 |
from transformers import pipeline, WhisperProcessor, WhisperForConditionalGeneration, Wav2Vec2Processor, Wav2Vec2Model
|
8 |
import torchaudio
|
|
|
9 |
|
10 |
# Load Whisper model to confirm English
|
11 |
whisper_pipe = pipeline("automatic-speech-recognition", model="openai/whisper-tiny", device="cpu")
|
|
|
21 |
}
|
22 |
|
23 |
def download_video(url):
|
24 |
+
video_path = tempfile.NamedTemporaryFile(suffix=".mp4", delete=False).name
|
25 |
+
response = requests.get(url, stream=True)
|
26 |
+
with open(video_path, "wb") as f:
|
27 |
+
for chunk in response.iter_content(chunk_size=1024*1024):
|
28 |
+
if chunk:
|
29 |
+
f.write(chunk)
|
30 |
+
return video_path
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
def extract_audio(video_path):
|
33 |
audio_path = tempfile.NamedTemporaryFile(suffix=".wav", delete=False).name
|
|
|
70 |
|
71 |
gr.Interface(
|
72 |
fn=analyze_accent,
|
73 |
+
inputs=gr.Textbox(label="Public Video URL (e.g. MP4)", placeholder="https://..."),
|
74 |
outputs=gr.Markdown(label="Accent Analysis Result"),
|
75 |
title="English Accent Classifier",
|
76 |
+
description="Paste a video URL (MP4) to extract audio, transcribe speech, and classify the English accent (e.g., American, British, etc.)."
|
77 |
).launch()
|