Spaces:
Runtime error
Runtime error
Commit
·
4b01587
1
Parent(s):
7860c23
Update app.py
Browse files
app.py
CHANGED
@@ -2,17 +2,15 @@ import torch
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import pytube as pt
|
5 |
-
from
|
6 |
from huggingface_hub import model_info
|
7 |
|
8 |
-
MODEL_NAME = "openai/whisper-small"
|
9 |
-
lang = "en"
|
10 |
|
11 |
device = 0 if torch.cuda.is_available() else "cpu"
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
chunk_length_s=30,
|
16 |
device=device,
|
17 |
)
|
18 |
|
@@ -31,9 +29,9 @@ def transcribe(microphone, file_upload):
|
|
31 |
|
32 |
file = microphone if microphone is not None else file_upload
|
33 |
|
34 |
-
text = pipe(file)
|
35 |
|
36 |
-
return warn_output + text
|
37 |
|
38 |
|
39 |
def _return_yt_html_embed(yt_url):
|
@@ -51,9 +49,9 @@ def yt_transcribe(yt_url):
|
|
51 |
stream = yt.streams.filter(only_audio=True)[0]
|
52 |
stream.download(filename="audio.mp3")
|
53 |
|
54 |
-
text = pipe("audio.mp3")
|
55 |
|
56 |
-
return html_embed_str, text
|
57 |
|
58 |
|
59 |
demo = gr.Blocks()
|
|
|
2 |
|
3 |
import gradio as gr
|
4 |
import pytube as pt
|
5 |
+
from asr_diarizer import ASRDiarizationPipeline
|
6 |
from huggingface_hub import model_info
|
7 |
|
8 |
+
MODEL_NAME = "openai/whisper-small"
|
|
|
9 |
|
10 |
device = 0 if torch.cuda.is_available() else "cpu"
|
11 |
+
|
12 |
+
pipe = ASRDiarizationPipeline(
|
13 |
+
asr_model=MODEL_NAME,
|
|
|
14 |
device=device,
|
15 |
)
|
16 |
|
|
|
29 |
|
30 |
file = microphone if microphone is not None else file_upload
|
31 |
|
32 |
+
text = pipe(file)
|
33 |
|
34 |
+
return warn_output + "\n\n".join([chunk["speaker"] + chunk["text"] for chunk in text])
|
35 |
|
36 |
|
37 |
def _return_yt_html_embed(yt_url):
|
|
|
49 |
stream = yt.streams.filter(only_audio=True)[0]
|
50 |
stream.download(filename="audio.mp3")
|
51 |
|
52 |
+
text = pipe("audio.mp3")
|
53 |
|
54 |
+
return html_embed_str, "\n\n".join([chunk["speaker"] + chunk["text"] for chunk in text])
|
55 |
|
56 |
|
57 |
demo = gr.Blocks()
|