Spaces:
Running
Running
Commit
·
1ed2d99
1
Parent(s):
1a71365
fixes
Browse filesSigned-off-by: Piotr Żelasko <[email protected]>
app.py
CHANGED
|
@@ -74,11 +74,16 @@ def postprocess(transcript, prompt):
|
|
| 74 |
ans = ans.split("<|im_start|>assistant")[-1] # get rid of the prompt
|
| 75 |
if "<think>" in ans:
|
| 76 |
ans = ans.split("<think>")[-1]
|
| 77 |
-
thoughts, ans = ans.split("</think>")
|
| 78 |
else:
|
| 79 |
thoughts = ""
|
| 80 |
return ans.strip(), thoughts
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
|
| 83 |
with gr.Blocks(
|
| 84 |
title="NeMo Canary-Qwen-2.5B Model",
|
|
@@ -162,15 +167,29 @@ with gr.Blocks(
|
|
| 162 |
)
|
| 163 |
|
| 164 |
asr_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
fn=transcribe,
|
| 166 |
inputs=[audio_file],
|
| 167 |
outputs=[transcript_box, raw_transcript]
|
|
|
|
|
|
|
|
|
|
| 168 |
)
|
| 169 |
|
| 170 |
llm_button.click(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 171 |
fn=postprocess,
|
| 172 |
inputs=[raw_transcript, prompt_box],
|
| 173 |
outputs=[magic_box, think_box]
|
|
|
|
|
|
|
|
|
|
| 174 |
)
|
| 175 |
|
| 176 |
|
|
|
|
| 74 |
ans = ans.split("<|im_start|>assistant")[-1] # get rid of the prompt
|
| 75 |
if "<think>" in ans:
|
| 76 |
ans = ans.split("<think>")[-1]
|
| 77 |
+
thoughts, ans = ans.split("</think>") # get rid of the thinking
|
| 78 |
else:
|
| 79 |
thoughts = ""
|
| 80 |
return ans.strip(), thoughts
|
| 81 |
|
| 82 |
+
def disable_buttons():
|
| 83 |
+
return gr.update(interactive=False), gr.update(interactive=False)
|
| 84 |
+
|
| 85 |
+
def enable_buttons():
|
| 86 |
+
return gr.update(interactive=True), gr.update(interactive=True)
|
| 87 |
|
| 88 |
with gr.Blocks(
|
| 89 |
title="NeMo Canary-Qwen-2.5B Model",
|
|
|
|
| 167 |
)
|
| 168 |
|
| 169 |
asr_button.click(
|
| 170 |
+
disable_buttons,
|
| 171 |
+
outputs=[asr_button, llm_button],
|
| 172 |
+
trigger_mode="once",
|
| 173 |
+
).then(
|
| 174 |
fn=transcribe,
|
| 175 |
inputs=[audio_file],
|
| 176 |
outputs=[transcript_box, raw_transcript]
|
| 177 |
+
).then(
|
| 178 |
+
enable_buttons,
|
| 179 |
+
outputs=[asr_button, llm_button],
|
| 180 |
)
|
| 181 |
|
| 182 |
llm_button.click(
|
| 183 |
+
disable_buttons,
|
| 184 |
+
outputs=[asr_button, llm_button],
|
| 185 |
+
trigger_mode="once",
|
| 186 |
+
).then(
|
| 187 |
fn=postprocess,
|
| 188 |
inputs=[raw_transcript, prompt_box],
|
| 189 |
outputs=[magic_box, think_box]
|
| 190 |
+
).then(
|
| 191 |
+
enable_buttons,
|
| 192 |
+
outputs=[asr_button, llm_button],
|
| 193 |
)
|
| 194 |
|
| 195 |
|