Skip to content

Commit

Permalink
Quick Fix: Multimodal microphone audio not clearing (#10322)
Browse files Browse the repository at this point in the history
* bug fix

* add changeset

* test

---------

Co-authored-by: gradio-pr-bot <[email protected]>
  • Loading branch information
dawoodkhan82 and gradio-pr-bot authored Jan 9, 2025
1 parent 391a4d0 commit d2691e7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/metal-bugs-follow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@gradio/multimodaltextbox": patch
"gradio": patch
---

fix:Quick Fix: Multimodal microphone audio not clearing
19 changes: 19 additions & 0 deletions js/multimodaltextbox/MultimodalTextbox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,23 @@ describe("MultimodalTextbox", () => {
assert.equal(mock.calls[8][0].detail.data.text, "hi some text");
assert.equal(mock.calls[8][0].detail.data.files.length, 0);
});

test("submitting should clear mic_audio", async () => {
const { component } = await render(MultimodalTextbox, {
show_label: true,
max_lines: 10,
loading_status,
lines: 1,
value: { text: "", files: [] },
label: "MultimodalTextbox",
interactive: true,
root: "",
sources: ["microphone"]
});

component.$set({ mic_audio: { url: "test.mp3", mime_type: "audio/mp3" } });
component.$set({ active_source: "microphone" });
await component.$$.ctx[component.$$.props["handle_submit"]];
assert.equal(component.mic_audio, null);
});
});
2 changes: 2 additions & 0 deletions js/multimodaltextbox/shared/MultimodalTextbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
if (mic_audio) {
value.files.push(mic_audio);
value = value;
mic_audio = null;
}
}
}
Expand Down Expand Up @@ -218,6 +219,7 @@
if (mic_audio) {
value.files.push(mic_audio);
value = value;
mic_audio = null;
}
}
Expand Down

0 comments on commit d2691e7

Please sign in to comment.