Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,8 +33,8 @@ def process_transcript(model, processor, language, audio_path):
|
|
| 33 |
else:
|
| 34 |
id_language = dict_languages[language]
|
| 35 |
inputs = processor.apply_transcrition_request(language=id_language, audio=audio_path, model_id=model_name)
|
| 36 |
-
inputs = inputs.to(device, dtype=torch.bfloat16)
|
| 37 |
-
|
| 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 |
|
|
@@ -59,20 +59,21 @@ with gr.Blocks(title="Transcription") as transcript:
|
|
| 59 |
with gr.Column():
|
| 60 |
sel_audio = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Upload an audio file or record via microphone:")
|
| 61 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
with gr.Row():
|
| 63 |
with gr.Column():
|
| 64 |
submit_transcript = gr.Button("Extract Transcription", variant="primary")
|
| 65 |
text_transcript = gr.Textbox(label="Generated Response", lines=10)
|
| 66 |
|
| 67 |
-
example = [["mapo_tofu.mp3"]]
|
| 68 |
-
gr.Examples(
|
| 69 |
-
examples=example,
|
| 70 |
-
inputs=sel_audio,
|
| 71 |
-
outputs=None,
|
| 72 |
-
fn=None,
|
| 73 |
-
cache_examples=False,
|
| 74 |
-
run_on_click=False
|
| 75 |
-
)
|
| 76 |
|
| 77 |
submit_transcript.click(
|
| 78 |
fn=lambda v1, v2: process_transcript(model, processor, v1, v2),
|
|
|
|
| 33 |
else:
|
| 34 |
id_language = dict_languages[language]
|
| 35 |
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 |
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 |
|
|
|
|
| 59 |
with gr.Column():
|
| 60 |
sel_audio = gr.Audio(sources=["microphone", "upload"], type="filepath", label="Upload an audio file or record via microphone:")
|
| 61 |
|
| 62 |
+
example = [["mapo_tofu.mp3"]]
|
| 63 |
+
gr.Examples(
|
| 64 |
+
examples=example,
|
| 65 |
+
inputs=sel_audio,
|
| 66 |
+
outputs=None,
|
| 67 |
+
fn=None,
|
| 68 |
+
cache_examples=False,
|
| 69 |
+
run_on_click=False
|
| 70 |
+
)
|
| 71 |
+
|
| 72 |
with gr.Row():
|
| 73 |
with gr.Column():
|
| 74 |
submit_transcript = gr.Button("Extract Transcription", variant="primary")
|
| 75 |
text_transcript = gr.Textbox(label="Generated Response", lines=10)
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
submit_transcript.click(
|
| 79 |
fn=lambda v1, v2: process_transcript(model, processor, v1, v2),
|