Spaces:
Runtime error
Runtime error
Commit
·
9d6fa91
1
Parent(s):
b95b5ca
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,6 +5,7 @@ import pytube as pt
|
|
| 5 |
from transformers import pipeline
|
| 6 |
|
| 7 |
MODEL_NAME = "openai/whisper-large-v2"
|
|
|
|
| 8 |
|
| 9 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 10 |
|
|
@@ -36,7 +37,7 @@ def transcribe(microphone, file_upload, task):
|
|
| 36 |
|
| 37 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
|
| 38 |
|
| 39 |
-
text = pipe(file)["text"]
|
| 40 |
|
| 41 |
return warn_output + text
|
| 42 |
|
|
@@ -58,7 +59,7 @@ def yt_transcribe(yt_url, task):
|
|
| 58 |
|
| 59 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
|
| 60 |
|
| 61 |
-
text = pipe("audio.mp3")["text"]
|
| 62 |
|
| 63 |
return html_embed_str, text
|
| 64 |
|
|
|
|
| 5 |
from transformers import pipeline
|
| 6 |
|
| 7 |
MODEL_NAME = "openai/whisper-large-v2"
|
| 8 |
+
BATCH_SIZE = 8
|
| 9 |
|
| 10 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 11 |
|
|
|
|
| 37 |
|
| 38 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
|
| 39 |
|
| 40 |
+
text = pipe(file, batch_size=BATCH_SIZE)["text"]
|
| 41 |
|
| 42 |
return warn_output + text
|
| 43 |
|
|
|
|
| 59 |
|
| 60 |
pipe.model.config.forced_decoder_ids = [[2, transcribe_token_id if task=="transcribe" else translate_token_id]]
|
| 61 |
|
| 62 |
+
text = pipe("audio.mp3", batch_size=BATCH_SIZE)["text"]
|
| 63 |
|
| 64 |
return html_embed_str, text
|
| 65 |
|