Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -32,9 +32,15 @@ def process_transcript(model, processor, language, audio_path):
|
|
| 32 |
return "Please provide some input audio: either upload an audio file or use the microphone."
|
| 33 |
else:
|
| 34 |
id_language = dict_languages[language]
|
| 35 |
-
|
| 36 |
# inputs = inputs.to(device, dtype=torch.bfloat16)
|
| 37 |
-
inputs = {k: v.to(device, dtype=torch.bfloat16) for k, v in inputs.items()}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
outputs = model.generate(**inputs, max_new_tokens=MAX_TOKENS)
|
| 39 |
decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 40 |
|
|
|
|
| 32 |
return "Please provide some input audio: either upload an audio file or use the microphone."
|
| 33 |
else:
|
| 34 |
id_language = dict_languages[language]
|
| 35 |
+
raw_inputs = processor.apply_transcrition_request(language=id_language, audio=audio_path, model_id=model_name)
|
| 36 |
# inputs = inputs.to(device, dtype=torch.bfloat16)
|
| 37 |
+
# inputs = {k: v.to(device, dtype=torch.bfloat16) for k, v in inputs.items()}
|
| 38 |
+
inputs = {}
|
| 39 |
+
for k, v in raw_inputs.items():
|
| 40 |
+
if k == "input_ids":
|
| 41 |
+
inputs[k] = v.to(device=device, dtype=torch.long)
|
| 42 |
+
else:
|
| 43 |
+
inputs[k] = v.to(device=device, dtype=torch.bfloat16)
|
| 44 |
outputs = model.generate(**inputs, max_new_tokens=MAX_TOKENS)
|
| 45 |
decoded_outputs = processor.batch_decode(outputs[:, inputs.input_ids.shape[1]:], skip_special_tokens=True)
|
| 46 |
|