Spaces:
Build error
Build error
Commit
·
6e899cf
1
Parent(s):
7630a02
fix issue
Browse files
app.py
CHANGED
|
@@ -6,22 +6,22 @@ import torch
|
|
| 6 |
MODEL_NAME = "openai/whisper-medium"
|
| 7 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
-
|
| 10 |
task="automatic-speech-recognition",
|
| 11 |
model=MODEL_NAME,
|
| 12 |
chunk_length_s=30,
|
| 13 |
device=device,
|
| 14 |
)
|
| 15 |
-
|
| 16 |
task="transcribe")
|
| 17 |
|
| 18 |
-
|
| 19 |
task="automatic-speech-recognition",
|
| 20 |
model=MODEL_NAME,
|
| 21 |
chunk_length_s=30,
|
| 22 |
device=device,
|
| 23 |
)
|
| 24 |
-
|
| 25 |
task="translate")
|
| 26 |
|
| 27 |
|
|
|
|
| 6 |
MODEL_NAME = "openai/whisper-medium"
|
| 7 |
device = 0 if torch.cuda.is_available() else "cpu"
|
| 8 |
|
| 9 |
+
transcriptor = pipeline(
|
| 10 |
task="automatic-speech-recognition",
|
| 11 |
model=MODEL_NAME,
|
| 12 |
chunk_length_s=30,
|
| 13 |
device=device,
|
| 14 |
)
|
| 15 |
+
transcriptor.model.config.forced_decoder_ids = transcriptor.tokenizer.get_decoder_prompt_ids(language='en',
|
| 16 |
task="transcribe")
|
| 17 |
|
| 18 |
+
translator = pipeline(
|
| 19 |
task="automatic-speech-recognition",
|
| 20 |
model=MODEL_NAME,
|
| 21 |
chunk_length_s=30,
|
| 22 |
device=device,
|
| 23 |
)
|
| 24 |
+
translator.model.config.forced_decoder_ids = translator.tokenizer.get_decoder_prompt_ids(language='es',
|
| 25 |
task="translate")
|
| 26 |
|
| 27 |
|