diff --git a/.changeset/metal-bugs-follow.md b/.changeset/metal-bugs-follow.md new file mode 100644 index 0000000000000..d9ac14f03b174 --- /dev/null +++ b/.changeset/metal-bugs-follow.md @@ -0,0 +1,6 @@ +--- +"@gradio/multimodaltextbox": patch +"gradio": patch +--- + +fix:Quick Fix: Multimodal microphone audio not clearing diff --git a/js/multimodaltextbox/MultimodalTextbox.test.ts b/js/multimodaltextbox/MultimodalTextbox.test.ts index d269f729ce369..a1560ed3554ce 100644 --- a/js/multimodaltextbox/MultimodalTextbox.test.ts +++ b/js/multimodaltextbox/MultimodalTextbox.test.ts @@ -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); + }); }); diff --git a/js/multimodaltextbox/shared/MultimodalTextbox.svelte b/js/multimodaltextbox/shared/MultimodalTextbox.svelte index 1bf1066006b3c..941dfc21a4d5a 100644 --- a/js/multimodaltextbox/shared/MultimodalTextbox.svelte +++ b/js/multimodaltextbox/shared/MultimodalTextbox.svelte @@ -157,6 +157,7 @@ if (mic_audio) { value.files.push(mic_audio); value = value; + mic_audio = null; } } } @@ -218,6 +219,7 @@ if (mic_audio) { value.files.push(mic_audio); value = value; + mic_audio = null; } }