Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -18,19 +18,25 @@ from transformers import AutoProcessor, pipeline
|
|
18 |
|
19 |
|
20 |
# Initialize processor and pipeline
|
21 |
-
processor = AutoProcessor.from_pretrained("NbAiLabBeta/nb-whisper-large")
|
22 |
-
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
23 |
-
torch_dtype = torch.float32
|
24 |
|
25 |
-
#
|
26 |
-
if processor.tokenizer.pad_token_id is None:
|
27 |
-
processor.tokenizer.pad_token_id = processor.tokenizer.convert_tokens_to_ids("[PAD]")
|
28 |
-
if processor.tokenizer.eos_token_id is None:
|
29 |
-
processor.tokenizer.eos_token_id = processor.tokenizer.convert_tokens_to_ids("[EOS]")
|
30 |
|
31 |
-
pipe = pipeline("automatic-speech-recognition", model="NbAiLabBeta/nb-whisper-large", torch_dtype=torch_dtype)
|
32 |
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
# task = "transcribe"
|
35 |
|
36 |
def transcribe_audio(audio_file):
|
@@ -185,7 +191,8 @@ def text_rank_summary(text, num_paragraphs=3):
|
|
185 |
|
186 |
banner_html = """
|
187 |
<div style="text-align: center;">
|
188 |
-
<img src="https://raw.huggingface.co/spaces/camparchimedes/transcription_app/blob/main/banner_trans.png
|
|
|
189 |
</div>
|
190 |
"""
|
191 |
# https://raw.huggingface.co/spaces/camparchimedes/transcription_app/blob/main/banner_trans.png
|
|
|
18 |
|
19 |
|
20 |
# Initialize processor and pipeline
|
|
|
|
|
|
|
21 |
|
22 |
+
# torch_dtype = torch.float32
|
|
|
|
|
|
|
|
|
23 |
|
|
|
24 |
|
25 |
+
MODEL_NAME = "NbAiLabBeta/nb-whisper-large"
|
26 |
+
|
27 |
+
language = "no"
|
28 |
+
|
29 |
+
device = "cuda" if torch.cuda.is_available() else "cpu"
|
30 |
+
pipe = pipeline(
|
31 |
+
task="automatic-speech-recognition",
|
32 |
+
model=MODEL_NAME,
|
33 |
+
chunk_length_s=30,
|
34 |
+
device=device,
|
35 |
+
)
|
36 |
+
|
37 |
+
|
38 |
+
pipe.model.config.forced_decoder_ids = pipe.tokenizer.get_decoder_prompt_ids(language=lang, task="transcribe")
|
39 |
+
|
40 |
# task = "transcribe"
|
41 |
|
42 |
def transcribe_audio(audio_file):
|
|
|
191 |
|
192 |
banner_html = """
|
193 |
<div style="text-align: center;">
|
194 |
+
<img src="https://raw.huggingface.co/spaces/camparchimedes/transcription_app/blob/main/banner_trans.png
|
195 |
+
" alt="" width="100%" height="auto">
|
196 |
</div>
|
197 |
"""
|
198 |
# https://raw.huggingface.co/spaces/camparchimedes/transcription_app/blob/main/banner_trans.png
|