Spaces:
Runtime error
Runtime error
Commit
•
485d132
1
Parent(s):
fc909b5
Update app.py
Browse files
app.py
CHANGED
@@ -4,9 +4,11 @@ import time
|
|
4 |
|
5 |
import gradio as gr
|
6 |
import numpy as np
|
|
|
7 |
import yt_dlp as youtube_dl
|
8 |
from gradio_client import Client
|
9 |
from pyannote.audio import Pipeline
|
|
|
10 |
|
11 |
|
12 |
YT_LENGTH_LIMIT_S = 36000 # limit to 1 hour YouTube files
|
@@ -222,8 +224,16 @@ def transcribe_yt(yt_url, task="transcribe", group_by_speaker=True, progress=gr.
|
|
222 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
223 |
filepath = os.path.join(tmpdirname, "video.mp4")
|
224 |
download_yt_audio(yt_url, filepath)
|
225 |
-
|
|
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
segments = diarization.for_json()["content"]
|
228 |
|
229 |
# only fetch the transcription result after performing diarization
|
|
|
4 |
|
5 |
import gradio as gr
|
6 |
import numpy as np
|
7 |
+
import torch
|
8 |
import yt_dlp as youtube_dl
|
9 |
from gradio_client import Client
|
10 |
from pyannote.audio import Pipeline
|
11 |
+
from transformers.pipelines.audio_utils import ffmpeg_read
|
12 |
|
13 |
|
14 |
YT_LENGTH_LIMIT_S = 36000 # limit to 1 hour YouTube files
|
|
|
224 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
225 |
filepath = os.path.join(tmpdirname, "video.mp4")
|
226 |
download_yt_audio(yt_url, filepath)
|
227 |
+
with open(filepath, "rb") as f:
|
228 |
+
inputs = f.read()
|
229 |
|
230 |
+
inputs = ffmpeg_read(inputs, SAMPLING_RATE)
|
231 |
+
inputs = torch.from_numpy(inputs).float()
|
232 |
+
inputs = inputs.unsqueeze(0)
|
233 |
+
|
234 |
+
diarization = diarization_pipeline(
|
235 |
+
{"waveform": inputs, "sample_rate": SAMPLING_RATE},
|
236 |
+
)
|
237 |
segments = diarization.for_json()["content"]
|
238 |
|
239 |
# only fetch the transcription result after performing diarization
|