@gradio/multimodaltextbox 0.14.4 → 0.15.0-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/Index.svelte +1 -0
- package/MultimodalTextbox.test.ts +39 -1
- package/dist/Index.svelte +1 -0
- package/dist/shared/MultimodalTextbox.svelte +4 -1
- package/dist/shared/MultimodalTextbox.svelte.d.ts +2 -1
- package/dist/types.d.ts +2 -1
- package/package.json +9 -8
- package/shared/MultimodalTextbox.svelte +4 -1
- package/types.ts +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @gradio/multimodaltextbox
|
|
2
2
|
|
|
3
|
+
## 0.15.0-dev.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- [#14002](https://github.com/gradio-app/gradio/pull/14002) [`dd82f43`](https://github.com/gradio-app/gradio/commit/dd82f435ee94c05ab9cdf946861a95ab77e72a47) - Remove `gradio sketch` and the vibe editor. Thanks @dawoodkhan82!
|
|
8
|
+
- [#13931](https://github.com/gradio-app/gradio/pull/13931) [`2c2b564`](https://github.com/gradio-app/gradio/commit/2c2b5642c3ed873bb53d1663fc2d36a6d53c00c9) - Let gr.Audio and gr.MultimodalTextbox pass media track constraints to the microphone. Thanks @hysts!
|
|
9
|
+
|
|
10
|
+
### Dependency updates
|
|
11
|
+
|
|
12
|
+
- @gradio/upload@0.19.2-dev.0
|
|
13
|
+
- @gradio/client@2.8.0-dev.0
|
|
14
|
+
- @gradio/audio@0.25.0-dev.0
|
|
15
|
+
- @gradio/image@0.29.0-dev.0
|
|
16
|
+
- @gradio/video@0.24.0-dev.0
|
|
17
|
+
|
|
3
18
|
## 0.14.4
|
|
4
19
|
|
|
5
20
|
### Dependency updates
|
package/Index.svelte
CHANGED
|
@@ -157,6 +157,7 @@
|
|
|
157
157
|
autoscroll={gradio.shared.autoscroll}
|
|
158
158
|
file_count={gradio.props.file_count}
|
|
159
159
|
{sources_string}
|
|
160
|
+
microphone_options={gradio.props.microphone_options}
|
|
160
161
|
max_file_size={gradio.shared.max_file_size}
|
|
161
162
|
onchange={(e) => {
|
|
162
163
|
gradio.props.value = e;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { test, describe, afterEach, expect } from "vitest";
|
|
1
|
+
import { test, describe, afterEach, expect, vi } from "vitest";
|
|
2
2
|
import {
|
|
3
3
|
cleanup,
|
|
4
4
|
render,
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { run_shared_prop_tests } from "@self/tootils/shared-prop-tests";
|
|
14
14
|
import event from "@testing-library/user-event";
|
|
15
15
|
import { tick } from "svelte";
|
|
16
|
+
import RecordPlugin from "wavesurfer.js/dist/plugins/record.js";
|
|
16
17
|
|
|
17
18
|
import MultimodalTextbox from "./Index.svelte";
|
|
18
19
|
|
|
@@ -154,6 +155,43 @@ describe("Props: sources", () => {
|
|
|
154
155
|
});
|
|
155
156
|
});
|
|
156
157
|
|
|
158
|
+
describe("Props: microphone_options", () => {
|
|
159
|
+
afterEach(() => {
|
|
160
|
+
vi.restoreAllMocks();
|
|
161
|
+
cleanup();
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test("constraints are passed to the mic along with the device", async () => {
|
|
165
|
+
const constraints = { echoCancellation: false, autoGainControl: true };
|
|
166
|
+
vi.spyOn(RecordPlugin, "getAvailableAudioDevices").mockResolvedValue([
|
|
167
|
+
{
|
|
168
|
+
deviceId: "mic-1",
|
|
169
|
+
label: "mic-1",
|
|
170
|
+
kind: "audioinput"
|
|
171
|
+
} as MediaDeviceInfo
|
|
172
|
+
]);
|
|
173
|
+
const start_mic = vi
|
|
174
|
+
.spyOn(RecordPlugin.prototype, "startMic")
|
|
175
|
+
.mockResolvedValue(new MediaStream());
|
|
176
|
+
vi.spyOn(RecordPlugin.prototype, "startRecording").mockResolvedValue(
|
|
177
|
+
undefined
|
|
178
|
+
);
|
|
179
|
+
const { getByRole } = await render(MultimodalTextbox, {
|
|
180
|
+
...default_props,
|
|
181
|
+
sources: ["microphone"],
|
|
182
|
+
microphone_options: { constraints }
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
await fireEvent.click(getByRole("button", { name: "Record audio" }));
|
|
186
|
+
|
|
187
|
+
await waitFor(() => expect(start_mic).toHaveBeenCalled());
|
|
188
|
+
expect(start_mic).toHaveBeenCalledWith({
|
|
189
|
+
...constraints,
|
|
190
|
+
deviceId: "mic-1"
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
|
|
157
195
|
describe("Props: submit_btn / stop_btn", () => {
|
|
158
196
|
afterEach(() => cleanup());
|
|
159
197
|
|
package/dist/Index.svelte
CHANGED
|
@@ -157,6 +157,7 @@
|
|
|
157
157
|
autoscroll={gradio.shared.autoscroll}
|
|
158
158
|
file_count={gradio.props.file_count}
|
|
159
159
|
{sources_string}
|
|
160
|
+
microphone_options={gradio.props.microphone_options}
|
|
160
161
|
max_file_size={gradio.shared.max_file_size}
|
|
161
162
|
onchange={(e) => {
|
|
162
163
|
gradio.props.value = e;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { Image } from "@gradio/image/shared";
|
|
7
7
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
8
8
|
import type { FileData, Client } from "@gradio/client";
|
|
9
|
-
import type { WaveformOptions } from "@gradio/audio";
|
|
9
|
+
import type { WaveformOptions, MicrophoneOptions } from "@gradio/audio";
|
|
10
10
|
import {
|
|
11
11
|
Clear,
|
|
12
12
|
File,
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
waveform_settings,
|
|
56
56
|
waveform_options: _waveform_options = { show_recording_waveform: true },
|
|
57
57
|
sources_string = "upload",
|
|
58
|
+
microphone_options = {},
|
|
58
59
|
active_source = $bindable<"microphone" | null>(),
|
|
59
60
|
html_attributes = null,
|
|
60
61
|
upload_promise = $bindable<Promise<any> | null>(),
|
|
@@ -98,6 +99,7 @@
|
|
|
98
99
|
max_plain_text_length?: number;
|
|
99
100
|
waveform_settings: Record<string, any>;
|
|
100
101
|
waveform_options?: WaveformOptions;
|
|
102
|
+
microphone_options?: MicrophoneOptions;
|
|
101
103
|
sources_string?:
|
|
102
104
|
| "upload"
|
|
103
105
|
| "upload,microphone"
|
|
@@ -417,6 +419,7 @@
|
|
|
417
419
|
{upload}
|
|
418
420
|
{root}
|
|
419
421
|
{max_file_size}
|
|
422
|
+
constraints={microphone_options.constraints ?? undefined}
|
|
420
423
|
bind:upload_promise
|
|
421
424
|
onchange={(audio_value) => {
|
|
422
425
|
mic_audio = audio_value;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
2
2
|
import type { FileData, Client } from "@gradio/client";
|
|
3
|
-
import type { WaveformOptions } from "@gradio/audio";
|
|
3
|
+
import type { WaveformOptions, MicrophoneOptions } from "@gradio/audio";
|
|
4
4
|
import { type SelectData } from "@gradio/utils";
|
|
5
5
|
import type { InputHTMLAttributes } from "./types";
|
|
6
6
|
type $$ComponentProps = {
|
|
@@ -32,6 +32,7 @@ type $$ComponentProps = {
|
|
|
32
32
|
max_plain_text_length?: number;
|
|
33
33
|
waveform_settings: Record<string, any>;
|
|
34
34
|
waveform_options?: WaveformOptions;
|
|
35
|
+
microphone_options?: MicrophoneOptions;
|
|
35
36
|
sources_string?: "upload" | "upload,microphone" | "microphone" | "microphone,upload";
|
|
36
37
|
active_source?: "microphone" | null;
|
|
37
38
|
html_attributes?: InputHTMLAttributes | null;
|
package/dist/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { FileData } from "@gradio/client";
|
|
|
2
2
|
import type { SelectData } from "@gradio/utils";
|
|
3
3
|
import type { ILoadingStatus as LoadingStatus } from "@gradio/statustracker";
|
|
4
4
|
import type { InputHTMLAttributes } from "./shared/types";
|
|
5
|
-
import type { WaveformOptions } from "js/audio/shared/types";
|
|
5
|
+
import type { WaveformOptions, MicrophoneOptions } from "js/audio/shared/types";
|
|
6
6
|
export interface MultimodalTextboxEvents {
|
|
7
7
|
change: {
|
|
8
8
|
text: string;
|
|
@@ -40,5 +40,6 @@ export interface MultimodalTextboxProps {
|
|
|
40
40
|
max_plain_text_length: number;
|
|
41
41
|
sources: ("microphone" | "upload")[];
|
|
42
42
|
waveform_options: WaveformOptions;
|
|
43
|
+
microphone_options?: MicrophoneOptions;
|
|
43
44
|
html_attributes: InputHTMLAttributes | null;
|
|
44
45
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gradio/multimodaltextbox",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0-dev.0",
|
|
4
4
|
"description": "Gradio UI packages",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "",
|
|
@@ -22,17 +22,18 @@
|
|
|
22
22
|
"./package.json": "./package.json"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@gradio/atoms": "^0.26.3",
|
|
26
25
|
"@gradio/icons": "^0.16.0",
|
|
27
|
-
"@gradio/
|
|
26
|
+
"@gradio/atoms": "^0.26.3",
|
|
28
27
|
"@gradio/statustracker": "^0.16.0",
|
|
29
|
-
"@gradio/
|
|
30
|
-
"@gradio/
|
|
31
|
-
"@gradio/
|
|
32
|
-
"@gradio/
|
|
33
|
-
"@gradio/
|
|
28
|
+
"@gradio/image": "^0.29.0-dev.0",
|
|
29
|
+
"@gradio/utils": "^0.15.0",
|
|
30
|
+
"@gradio/upload": "^0.19.2-dev.0",
|
|
31
|
+
"@gradio/video": "^0.24.0-dev.0",
|
|
32
|
+
"@gradio/client": "^2.8.0-dev.0",
|
|
33
|
+
"@gradio/audio": "^0.25.0-dev.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"wavesurfer.js": "7.11.0",
|
|
36
37
|
"@gradio/preview": "^0.17.1"
|
|
37
38
|
},
|
|
38
39
|
"peerDependencies": {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { Image } from "@gradio/image/shared";
|
|
7
7
|
import type { I18nFormatter } from "js/core/src/gradio_helper";
|
|
8
8
|
import type { FileData, Client } from "@gradio/client";
|
|
9
|
-
import type { WaveformOptions } from "@gradio/audio";
|
|
9
|
+
import type { WaveformOptions, MicrophoneOptions } from "@gradio/audio";
|
|
10
10
|
import {
|
|
11
11
|
Clear,
|
|
12
12
|
File,
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
waveform_settings,
|
|
56
56
|
waveform_options: _waveform_options = { show_recording_waveform: true },
|
|
57
57
|
sources_string = "upload",
|
|
58
|
+
microphone_options = {},
|
|
58
59
|
active_source = $bindable<"microphone" | null>(),
|
|
59
60
|
html_attributes = null,
|
|
60
61
|
upload_promise = $bindable<Promise<any> | null>(),
|
|
@@ -98,6 +99,7 @@
|
|
|
98
99
|
max_plain_text_length?: number;
|
|
99
100
|
waveform_settings: Record<string, any>;
|
|
100
101
|
waveform_options?: WaveformOptions;
|
|
102
|
+
microphone_options?: MicrophoneOptions;
|
|
101
103
|
sources_string?:
|
|
102
104
|
| "upload"
|
|
103
105
|
| "upload,microphone"
|
|
@@ -417,6 +419,7 @@
|
|
|
417
419
|
{upload}
|
|
418
420
|
{root}
|
|
419
421
|
{max_file_size}
|
|
422
|
+
constraints={microphone_options.constraints ?? undefined}
|
|
420
423
|
bind:upload_promise
|
|
421
424
|
onchange={(audio_value) => {
|
|
422
425
|
mic_audio = audio_value;
|
package/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { FileData } from "@gradio/client";
|
|
|
2
2
|
import type { SelectData } from "@gradio/utils";
|
|
3
3
|
import type { ILoadingStatus as LoadingStatus } from "@gradio/statustracker";
|
|
4
4
|
import type { InputHTMLAttributes } from "./shared/types";
|
|
5
|
-
import type { WaveformOptions } from "js/audio/shared/types";
|
|
5
|
+
import type { WaveformOptions, MicrophoneOptions } from "js/audio/shared/types";
|
|
6
6
|
|
|
7
7
|
export interface MultimodalTextboxEvents {
|
|
8
8
|
change: { text: string; files: FileData[] };
|
|
@@ -36,5 +36,6 @@ export interface MultimodalTextboxProps {
|
|
|
36
36
|
max_plain_text_length: number;
|
|
37
37
|
sources: ("microphone" | "upload")[];
|
|
38
38
|
waveform_options: WaveformOptions;
|
|
39
|
+
microphone_options?: MicrophoneOptions;
|
|
39
40
|
html_attributes: InputHTMLAttributes | null;
|
|
40
41
|
}
|