gradio-pr-bot commited on
Commit
a60d004
·
verified ·
1 Parent(s): fddf074

Upload folder using huggingface_hub

Browse files
6.0.0-dev.6/multimodaltextbox/Index.svelte CHANGED
@@ -39,8 +39,8 @@
39
 
40
  const value = $derived(gradio.props.value || { text: "", files: [] });
41
 
42
- let dragging: boolean;
43
- let active_source: "microphone" | null = null;
44
 
45
  let color_accent = "darkorange";
46
 
 
39
 
40
  const value = $derived(gradio.props.value || { text: "", files: [] });
41
 
42
+ let dragging = $state<boolean>(false);
43
+ let active_source = $state<"microphone" | null>(null);
44
 
45
  let color_accent = "darkorange";
46
 
6.0.0-dev.6/multimodaltextbox/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "@gradio/multimodaltextbox",
3
- "version": "0.11.0-dev.2",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
 
1
  {
2
  "name": "@gradio/multimodaltextbox",
3
+ "version": "0.11.0-dev.3",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
6.0.0-dev.6/multimodaltextbox/shared/MultimodalTextbox.svelte CHANGED
@@ -21,10 +21,15 @@
21
  Video,
22
  ArrowUp,
23
  Square,
24
- Microphone
 
25
  } from "@gradio/icons";
26
  import type { SelectData } from "@gradio/utils";
27
  import { BaseInteractiveAudio as InteractiveAudio } from "@gradio/audio";
 
 
 
 
28
  import type { InputHTMLAttributes } from "./types";
29
 
30
  export let value: { text: string; files: FileData[] } = {
@@ -181,10 +186,10 @@
181
  max_lines >= 1
182
  ) {
183
  e.preventDefault();
 
 
184
  await tick();
185
  dispatch("submit");
186
- active_source = null;
187
- add_mic_audio_to_files();
188
  }
189
  }
190
 
@@ -241,13 +246,14 @@
241
  value.files.push(mic_audio);
242
  value = value;
243
  mic_audio = null;
 
244
  }
245
  }
246
 
247
  function handle_submit(): void {
248
- dispatch("submit");
249
- active_source = null;
250
  add_mic_audio_to_files();
 
 
251
  }
252
 
253
  async function handle_paste(event: ClipboardEvent): Promise<void> {
@@ -343,36 +349,71 @@
343
  <BlockTitle {show_label} {info} {rtl}>{label}</BlockTitle>
344
  <div class="input-container">
345
  {#if sources && sources.includes("microphone") && active_source === "microphone"}
346
- <InteractiveAudio
347
- on:change={({ detail }) => {
348
- if (detail !== null) {
349
- mic_audio = detail;
350
- }
351
- }}
352
- on:clear={() => {
353
- active_source = null;
354
- }}
355
- on:start_recording={() => dispatch("start_recording")}
356
- on:pause_recording={() => dispatch("pause_recording")}
357
- on:stop_recording={() => dispatch("stop_recording")}
358
- sources={["microphone"]}
359
- class_name="compact-audio"
360
- {recording}
361
- {waveform_settings}
362
- {waveform_options}
363
- {i18n}
364
- {active_source}
365
- {upload}
366
- {stream_handler}
367
- stream_every={1}
368
- editable={true}
369
- {label}
370
- {root}
371
- loop={false}
372
- show_label={false}
373
- buttons={[]}
374
- dragging={false}
375
- />
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  {/if}
377
  {#if show_upload}
378
  <Upload
@@ -407,7 +448,7 @@
407
  {#if show_upload}
408
  <button
409
  data-testid="upload-button"
410
- class="upload-button mobile-thumbnail-add"
411
  {disabled}
412
  on:click={handle_upload_click}
413
  aria-label="Upload a file"
@@ -492,9 +533,15 @@
492
  class="microphone-button"
493
  class:recording
494
  {disabled}
495
- on:click={() => {
496
- active_source =
497
- active_source !== "microphone" ? "microphone" : null;
 
 
 
 
 
 
498
  }}
499
  aria-label="Record audio"
500
  >
@@ -626,7 +673,6 @@
626
  display: flex;
627
  justify-content: center;
628
  align-items: center;
629
- border: var(--size-px) solid var(--border-color-primary);
630
  border-radius: var(--radius-md);
631
  background: var(--background-fill-secondary);
632
  width: var(--size-full);
@@ -712,7 +758,6 @@
712
  transform: scaleX(-1);
713
  }
714
 
715
- .mobile-thumbnail-add,
716
  .microphone-button {
717
  color: var(--body-text-color);
718
  cursor: pointer;
@@ -722,14 +767,33 @@
722
  align-items: center;
723
  flex-shrink: 0;
724
  border-radius: var(--radius-md);
725
- transition:
726
- background 0.2s var(--easing-standard),
727
- border-color 0.2s var(--easing-standard);
728
  }
729
 
730
- .mobile-thumbnail-add {
 
 
 
 
 
 
731
  width: var(--size-10);
732
  height: var(--size-10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
733
  }
734
 
735
  .microphone-button {
@@ -737,19 +801,15 @@
737
  height: var(--size-9);
738
  }
739
 
740
- .mobile-thumbnail-add:hover:not(:disabled),
741
  .microphone-button:hover:not(:disabled) {
742
- background: var(--button-secondary-background-fill-hover);
743
- border-color: var(--border-color-primary);
744
  }
745
 
746
- .mobile-thumbnail-add:disabled,
747
  .microphone-button:disabled {
748
  opacity: 0.5;
749
  cursor: not-allowed;
750
  }
751
 
752
- .mobile-thumbnail-add :global(svg),
753
  .microphone-button :global(svg) {
754
  width: var(--size-5);
755
  height: var(--size-5);
@@ -757,7 +817,6 @@
757
 
758
  .submit-button,
759
  .stop-button {
760
- border: var(--size-px) solid var(--border-color-primary);
761
  background: var(--button-secondary-background-fill);
762
  cursor: pointer;
763
  display: flex;
@@ -768,9 +827,6 @@
768
  height: var(--size-9);
769
  border-radius: var(--radius-md);
770
  z-index: var(--layer-1);
771
- transition:
772
- background 0.2s var(--easing-standard),
773
- border-color 0.2s var(--easing-standard);
774
  }
775
 
776
  .submit-button:hover:not(:disabled),
@@ -820,6 +876,112 @@
820
  }
821
  }
822
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
823
  @media (max-width: 768px) {
824
  .input-wrapper {
825
  padding: var(--spacing-xs);
@@ -831,7 +993,7 @@
831
  }
832
 
833
  .thumbnail-small,
834
- .mobile-thumbnail-add {
835
  width: var(--size-9);
836
  height: var(--size-9);
837
  }
 
21
  Video,
22
  ArrowUp,
23
  Square,
24
+ Microphone,
25
+ Check
26
  } from "@gradio/icons";
27
  import type { SelectData } from "@gradio/utils";
28
  import { BaseInteractiveAudio as InteractiveAudio } from "@gradio/audio";
29
+ import {
30
+ MinimalAudioPlayer,
31
+ MinimalAudioRecorder
32
+ } from "@gradio/audio/shared";
33
  import type { InputHTMLAttributes } from "./types";
34
 
35
  export let value: { text: string; files: FileData[] } = {
 
186
  max_lines >= 1
187
  ) {
188
  e.preventDefault();
189
+ add_mic_audio_to_files();
190
+ active_source = null;
191
  await tick();
192
  dispatch("submit");
 
 
193
  }
194
  }
195
 
 
246
  value.files.push(mic_audio);
247
  value = value;
248
  mic_audio = null;
249
+ dispatch("change", value);
250
  }
251
  }
252
 
253
  function handle_submit(): void {
 
 
254
  add_mic_audio_to_files();
255
+ active_source = null;
256
+ dispatch("submit");
257
  }
258
 
259
  async function handle_paste(event: ClipboardEvent): Promise<void> {
 
349
  <BlockTitle {show_label} {info} {rtl}>{label}</BlockTitle>
350
  <div class="input-container">
351
  {#if sources && sources.includes("microphone") && active_source === "microphone"}
352
+ <div class="recording-overlay" class:has-audio={mic_audio !== null}>
353
+ {#if !mic_audio}
354
+ <div class="recording-content">
355
+ <MinimalAudioRecorder
356
+ label={label || "Audio"}
357
+ {waveform_settings}
358
+ {recording}
359
+ {upload}
360
+ {root}
361
+ {max_file_size}
362
+ bind:upload_promise
363
+ on:change={({ detail }) => {
364
+ mic_audio = detail;
365
+ }}
366
+ on:stop_recording={() => {
367
+ recording = false;
368
+ dispatch("stop_recording");
369
+ }}
370
+ on:clear={() => {
371
+ active_source = null;
372
+ recording = false;
373
+ mic_audio = null;
374
+ }}
375
+ on:error={({ detail }) => {
376
+ console.log("Failed to record:", detail);
377
+ active_source = null;
378
+ recording = false;
379
+ mic_audio = null;
380
+ }}
381
+ />
382
+ </div>
383
+ {:else}
384
+ <div class="recording-content">
385
+ <MinimalAudioPlayer
386
+ value={mic_audio}
387
+ label={label || "Audio"}
388
+ loop={false}
389
+ />
390
+ <div class="action-buttons">
391
+ <button
392
+ class="confirm-button"
393
+ on:click={() => {
394
+ add_mic_audio_to_files();
395
+ active_source = null;
396
+ recording = false;
397
+ }}
398
+ aria-label="Attach audio"
399
+ >
400
+ <Check />
401
+ </button>
402
+ <button
403
+ class="cancel-button"
404
+ on:click={() => {
405
+ active_source = null;
406
+ recording = false;
407
+ mic_audio = null;
408
+ }}
409
+ aria-label="Clear audio"
410
+ >
411
+ <Clear />
412
+ </button>
413
+ </div>
414
+ </div>
415
+ {/if}
416
+ </div>
417
  {/if}
418
  {#if show_upload}
419
  <Upload
 
448
  {#if show_upload}
449
  <button
450
  data-testid="upload-button"
451
+ class="upload-button thumbnail-add"
452
  {disabled}
453
  on:click={handle_upload_click}
454
  aria-label="Upload a file"
 
533
  class="microphone-button"
534
  class:recording
535
  {disabled}
536
+ on:click={async () => {
537
+ if (active_source !== "microphone") {
538
+ active_source = "microphone";
539
+ await tick();
540
+ recording = true;
541
+ } else {
542
+ active_source = null;
543
+ recording = false;
544
+ }
545
  }}
546
  aria-label="Record audio"
547
  >
 
673
  display: flex;
674
  justify-content: center;
675
  align-items: center;
 
676
  border-radius: var(--radius-md);
677
  background: var(--background-fill-secondary);
678
  width: var(--size-full);
 
758
  transform: scaleX(-1);
759
  }
760
 
 
761
  .microphone-button {
762
  color: var(--body-text-color);
763
  cursor: pointer;
 
767
  align-items: center;
768
  flex-shrink: 0;
769
  border-radius: var(--radius-md);
 
 
 
770
  }
771
 
772
+ .thumbnail-add {
773
+ background: var(--button-secondary-background-fill);
774
+ cursor: pointer;
775
+ display: flex;
776
+ justify-content: center;
777
+ align-items: center;
778
+ flex-shrink: 0;
779
  width: var(--size-10);
780
  height: var(--size-10);
781
+ border-radius: var(--radius-md);
782
+ z-index: var(--layer-1);
783
+ }
784
+
785
+ .thumbnail-add:hover:not(:disabled) {
786
+ background: var(--button-secondary-background-fill-hover);
787
+ }
788
+
789
+ .thumbnail-add:disabled {
790
+ opacity: 0.5;
791
+ cursor: not-allowed;
792
+ }
793
+
794
+ .thumbnail-add :global(svg) {
795
+ width: var(--size-5);
796
+ height: var(--size-5);
797
  }
798
 
799
  .microphone-button {
 
801
  height: var(--size-9);
802
  }
803
 
 
804
  .microphone-button:hover:not(:disabled) {
805
+ background: var(--button-secondary-background-fill);
 
806
  }
807
 
 
808
  .microphone-button:disabled {
809
  opacity: 0.5;
810
  cursor: not-allowed;
811
  }
812
 
 
813
  .microphone-button :global(svg) {
814
  width: var(--size-5);
815
  height: var(--size-5);
 
817
 
818
  .submit-button,
819
  .stop-button {
 
820
  background: var(--button-secondary-background-fill);
821
  cursor: pointer;
822
  display: flex;
 
827
  height: var(--size-9);
828
  border-radius: var(--radius-md);
829
  z-index: var(--layer-1);
 
 
 
830
  }
831
 
832
  .submit-button:hover:not(:disabled),
 
876
  }
877
  }
878
 
879
+ .recording-overlay {
880
+ position: absolute;
881
+ top: 0;
882
+ left: 0;
883
+ right: 0;
884
+ bottom: 0;
885
+ background: var(--block-background-fill);
886
+ border-radius: var(--radius-xl);
887
+ display: flex;
888
+ align-items: center;
889
+ justify-content: center;
890
+ z-index: var(--layer-5);
891
+ padding: var(--spacing-lg);
892
+ backdrop-filter: blur(8px);
893
+ animation: fadeIn 0.2s var(--easing-standard);
894
+ }
895
+
896
+ @keyframes fadeIn {
897
+ from {
898
+ opacity: 0;
899
+ }
900
+ to {
901
+ opacity: 1;
902
+ }
903
+ }
904
+
905
+ .recording-content {
906
+ display: flex;
907
+ align-items: center;
908
+ gap: var(--spacing-lg);
909
+ width: 100%;
910
+ max-width: 700px;
911
+ }
912
+
913
+ .recording-content :global(.minimal-audio-recorder),
914
+ .recording-content :global(.minimal-audio-player) {
915
+ flex: 1;
916
+ }
917
+
918
+ .action-buttons {
919
+ display: flex;
920
+ align-items: center;
921
+ gap: var(--spacing-sm);
922
+ flex-shrink: 0;
923
+ }
924
+
925
+ .stop-button,
926
+ .confirm-button,
927
+ .cancel-button {
928
+ display: flex;
929
+ align-items: center;
930
+ justify-content: center;
931
+ width: var(--size-9);
932
+ height: var(--size-9);
933
+ padding: 0;
934
+ border-radius: var(--radius-md);
935
+ cursor: pointer;
936
+ flex-shrink: 0;
937
+ }
938
+
939
+ .stop-button {
940
+ background: var(--button-secondary-background-fill);
941
+ border-color: var(--border-color-primary);
942
+ color: var(--error-500);
943
+ }
944
+
945
+ .stop-button:hover {
946
+ background: var(--button-secondary-background-fill-hover);
947
+ color: var(--error-600);
948
+ }
949
+
950
+ .stop-button:active {
951
+ transform: scale(0.95);
952
+ }
953
+
954
+ .confirm-button {
955
+ background: var(--button-primary-background-fill);
956
+ border-color: var(--button-primary-border-color);
957
+ color: white;
958
+ }
959
+
960
+ .confirm-button:hover {
961
+ background: var(--button-primary-background-fill-hover);
962
+ color: var(--button-primary-text-color-hover);
963
+ }
964
+
965
+ .confirm-button:active {
966
+ transform: scale(0.95);
967
+ }
968
+
969
+ .cancel-button {
970
+ background: var(--button-secondary-background-fill);
971
+ color: var(--body-text-color);
972
+ }
973
+
974
+ .cancel-button:hover {
975
+ background: var(--button-secondary-background-fill-hover);
976
+ }
977
+
978
+ .stop-button :global(svg),
979
+ .confirm-button :global(svg),
980
+ .cancel-button :global(svg) {
981
+ width: var(--size-5);
982
+ height: var(--size-5);
983
+ }
984
+
985
  @media (max-width: 768px) {
986
  .input-wrapper {
987
  padding: var(--spacing-xs);
 
993
  }
994
 
995
  .thumbnail-small,
996
+ .thumbnail-add {
997
  width: var(--size-9);
998
  height: var(--size-9);
999
  }