Spaces:
Running
on
T4
Running
on
T4
Update app.py
#1
by
AngelinaZanardi
- opened
app.py
CHANGED
@@ -19,6 +19,8 @@ import yt_dlp # Added import for yt-dlp
|
|
19 |
MODEL_NAME = "NbAiLab/nb-whisper-large"
|
20 |
lang = "no"
|
21 |
|
|
|
|
|
22 |
share = (os.environ.get("SHARE", "False")[0].lower() in "ty1") or None
|
23 |
auth_token = os.environ.get("AUTH_TOKEN") or True
|
24 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
@@ -29,7 +31,7 @@ def pipe(file, return_timestamps=False):
|
|
29 |
asr = pipeline(
|
30 |
task="automatic-speech-recognition",
|
31 |
model=MODEL_NAME,
|
32 |
-
chunk_length_s=
|
33 |
device=device,
|
34 |
token=auth_token,
|
35 |
torch_dtype=torch.float16,
|
@@ -62,6 +64,7 @@ def transcribe(file, return_timestamps=False):
|
|
62 |
line = f"[{start_time} -> {end_time}] {chunk['text']}"
|
63 |
text.append(line)
|
64 |
formatted_text = "\n".join(text)
|
|
|
65 |
return formatted_text
|
66 |
|
67 |
def _return_yt_html_embed(yt_url):
|
@@ -97,6 +100,8 @@ def yt_transcribe(yt_url, return_timestamps=False):
|
|
97 |
demo = gr.Blocks()
|
98 |
|
99 |
with demo:
|
|
|
|
|
100 |
mf_transcribe = gr.Interface(
|
101 |
fn=transcribe,
|
102 |
inputs=[
|
@@ -110,6 +115,7 @@ with demo:
|
|
110 |
f" modellen [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) og 🤗 Transformers til å transkribere lydfiler opp til 30 minutter."
|
111 |
),
|
112 |
allow_flagging="never",
|
|
|
113 |
)
|
114 |
|
115 |
# Uncomment to add the YouTube transcription interface if needed
|
|
|
19 |
MODEL_NAME = "NbAiLab/nb-whisper-large"
|
20 |
lang = "no"
|
21 |
|
22 |
+
logo_path = "home/angelina/Nedlastinger/Screenshot 2024-10-10 at 13-30-13 Nasjonalbiblioteket — Melkeveien designkontor.png"
|
23 |
+
|
24 |
share = (os.environ.get("SHARE", "False")[0].lower() in "ty1") or None
|
25 |
auth_token = os.environ.get("AUTH_TOKEN") or True
|
26 |
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
|
|
31 |
asr = pipeline(
|
32 |
task="automatic-speech-recognition",
|
33 |
model=MODEL_NAME,
|
34 |
+
chunk_length_s=28,
|
35 |
device=device,
|
36 |
token=auth_token,
|
37 |
torch_dtype=torch.float16,
|
|
|
64 |
line = f"[{start_time} -> {end_time}] {chunk['text']}"
|
65 |
text.append(line)
|
66 |
formatted_text = "\n".join(text)
|
67 |
+
formatted_text += "\n\nTranskribert med NB-Whisper demo"
|
68 |
return formatted_text
|
69 |
|
70 |
def _return_yt_html_embed(yt_url):
|
|
|
100 |
demo = gr.Blocks()
|
101 |
|
102 |
with demo:
|
103 |
+
gr.Image(value=logo_path, label="Nasjonalbibliotek Logo", elem_id="logo")
|
104 |
+
|
105 |
mf_transcribe = gr.Interface(
|
106 |
fn=transcribe,
|
107 |
inputs=[
|
|
|
115 |
f" modellen [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) og 🤗 Transformers til å transkribere lydfiler opp til 30 minutter."
|
116 |
),
|
117 |
allow_flagging="never",
|
118 |
+
show_submit_button=False,
|
119 |
)
|
120 |
|
121 |
# Uncomment to add the YouTube transcription interface if needed
|