Upload folder using huggingface_hub
Browse files
6.2.0/audio/Index.svelte
CHANGED
|
@@ -147,6 +147,9 @@
|
|
| 147 |
waveform_options={gradio.props.waveform_options}
|
| 148 |
editable={gradio.props.editable}
|
| 149 |
{minimal}
|
|
|
|
|
|
|
|
|
|
| 150 |
bind:playback_position={gradio.props.playback_position}
|
| 151 |
on:share={(e) => gradio.dispatch("share", e.detail)}
|
| 152 |
on:error={(e) => gradio.dispatch("error", e.detail)}
|
|
@@ -183,6 +186,9 @@
|
|
| 183 |
{label}
|
| 184 |
show_label={gradio.shared.show_label}
|
| 185 |
buttons={gradio.props.buttons ?? []}
|
|
|
|
|
|
|
|
|
|
| 186 |
value={gradio.props.value}
|
| 187 |
subtitles={gradio.props.subtitles}
|
| 188 |
on:change={({ detail }) => (gradio.props.value = detail)}
|
|
|
|
| 147 |
waveform_options={gradio.props.waveform_options}
|
| 148 |
editable={gradio.props.editable}
|
| 149 |
{minimal}
|
| 150 |
+
on_custom_button_click={(id) => {
|
| 151 |
+
gradio.dispatch("custom_button_click", { id });
|
| 152 |
+
}}
|
| 153 |
bind:playback_position={gradio.props.playback_position}
|
| 154 |
on:share={(e) => gradio.dispatch("share", e.detail)}
|
| 155 |
on:error={(e) => gradio.dispatch("error", e.detail)}
|
|
|
|
| 186 |
{label}
|
| 187 |
show_label={gradio.shared.show_label}
|
| 188 |
buttons={gradio.props.buttons ?? []}
|
| 189 |
+
on_custom_button_click={(id) => {
|
| 190 |
+
gradio.dispatch("custom_button_click", { id });
|
| 191 |
+
}}
|
| 192 |
value={gradio.props.value}
|
| 193 |
subtitles={gradio.props.subtitles}
|
| 194 |
on:change={({ detail }) => (gradio.props.value = detail)}
|
6.2.0/audio/interactive/InteractiveAudio.svelte
CHANGED
|
@@ -2,8 +2,9 @@
|
|
| 2 |
import { onDestroy, createEventDispatcher, tick } from "svelte";
|
| 3 |
import { Upload, ModifyUpload } from "@gradio/upload";
|
| 4 |
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
| 5 |
-
import { BlockLabel } from "@gradio/atoms";
|
| 6 |
import { Music } from "@gradio/icons";
|
|
|
|
| 7 |
import { StreamingBar } from "@gradio/statustracker";
|
| 8 |
import AudioPlayer from "../player/AudioPlayer.svelte";
|
| 9 |
|
|
@@ -22,7 +23,9 @@
|
|
| 22 |
export let root: string;
|
| 23 |
export let loop: boolean;
|
| 24 |
export let show_label = true;
|
| 25 |
-
|
|
|
|
|
|
|
| 26 |
export let sources:
|
| 27 |
| ["microphone"]
|
| 28 |
| ["upload"]
|
|
@@ -297,10 +300,39 @@
|
|
| 297 |
on:edit={() => (mode = "edit")}
|
| 298 |
download={buttons === null
|
| 299 |
? value.url
|
| 300 |
-
: buttons.
|
| 301 |
? value.url
|
| 302 |
: null}
|
| 303 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 304 |
|
| 305 |
<AudioPlayer
|
| 306 |
bind:mode
|
|
|
|
| 2 |
import { onDestroy, createEventDispatcher, tick } from "svelte";
|
| 3 |
import { Upload, ModifyUpload } from "@gradio/upload";
|
| 4 |
import { prepare_files, type FileData, type Client } from "@gradio/client";
|
| 5 |
+
import { BlockLabel, ShareButton, CustomButton } from "@gradio/atoms";
|
| 6 |
import { Music } from "@gradio/icons";
|
| 7 |
+
import { uploadToHuggingFace } from "@gradio/utils";
|
| 8 |
import { StreamingBar } from "@gradio/statustracker";
|
| 9 |
import AudioPlayer from "../player/AudioPlayer.svelte";
|
| 10 |
|
|
|
|
| 23 |
export let root: string;
|
| 24 |
export let loop: boolean;
|
| 25 |
export let show_label = true;
|
| 26 |
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
| 27 |
+
export let buttons: (string | CustomButtonType)[] = ["download", "share"];
|
| 28 |
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
| 29 |
export let sources:
|
| 30 |
| ["microphone"]
|
| 31 |
| ["upload"]
|
|
|
|
| 300 |
on:edit={() => (mode = "edit")}
|
| 301 |
download={buttons === null
|
| 302 |
? value.url
|
| 303 |
+
: buttons.some((btn) => typeof btn === "string" && btn === "download")
|
| 304 |
? value.url
|
| 305 |
: null}
|
| 306 |
+
>
|
| 307 |
+
{#if value !== null && buttons}
|
| 308 |
+
{#each buttons as btn}
|
| 309 |
+
{#if typeof btn === "string"}
|
| 310 |
+
{#if btn === "share"}
|
| 311 |
+
<ShareButton
|
| 312 |
+
{i18n}
|
| 313 |
+
on:error
|
| 314 |
+
on:share
|
| 315 |
+
formatter={async (value) => {
|
| 316 |
+
if (!value) return "";
|
| 317 |
+
let url = await uploadToHuggingFace(value.url, "url");
|
| 318 |
+
return `<audio controls src="${url}"></audio>`;
|
| 319 |
+
}}
|
| 320 |
+
{value}
|
| 321 |
+
/>
|
| 322 |
+
{/if}
|
| 323 |
+
{:else}
|
| 324 |
+
<CustomButton
|
| 325 |
+
button={btn}
|
| 326 |
+
on_click={(id) => {
|
| 327 |
+
if (on_custom_button_click) {
|
| 328 |
+
on_custom_button_click(id);
|
| 329 |
+
}
|
| 330 |
+
}}
|
| 331 |
+
/>
|
| 332 |
+
{/if}
|
| 333 |
+
{/each}
|
| 334 |
+
{/if}
|
| 335 |
+
</ModifyUpload>
|
| 336 |
|
| 337 |
<AudioPlayer
|
| 338 |
bind:mode
|
6.2.0/audio/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/audio",
|
| 3 |
-
"version": "0.
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
|
|
|
| 1 |
{
|
| 2 |
"name": "@gradio/audio",
|
| 3 |
+
"version": "0.22.0",
|
| 4 |
"description": "Gradio UI packages",
|
| 5 |
"type": "module",
|
| 6 |
"author": "",
|
6.2.0/audio/shared/types.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
import { FileData } from "@gradio/client";
|
|
|
|
| 2 |
|
| 3 |
export type WaveformOptions = {
|
| 4 |
waveform_color?: string;
|
|
@@ -25,7 +26,7 @@ export interface AudioProps {
|
|
| 25 |
value: FileData | null;
|
| 26 |
type: "numpy" | "filepath";
|
| 27 |
autoplay: boolean;
|
| 28 |
-
buttons: ("play" | "download")[];
|
| 29 |
recording: boolean;
|
| 30 |
loop: boolean;
|
| 31 |
subtitles: FileData | SubtitleData[] | null;
|
|
@@ -56,4 +57,5 @@ export interface AudioEvents {
|
|
| 56 |
clear_status: any;
|
| 57 |
close_stream: any;
|
| 58 |
edit: any;
|
|
|
|
| 59 |
}
|
|
|
|
| 1 |
import { FileData } from "@gradio/client";
|
| 2 |
+
import type { CustomButton } from "@gradio/utils";
|
| 3 |
|
| 4 |
export type WaveformOptions = {
|
| 5 |
waveform_color?: string;
|
|
|
|
| 26 |
value: FileData | null;
|
| 27 |
type: "numpy" | "filepath";
|
| 28 |
autoplay: boolean;
|
| 29 |
+
buttons: ("play" | "download" | "share" | CustomButton)[];
|
| 30 |
recording: boolean;
|
| 31 |
loop: boolean;
|
| 32 |
subtitles: FileData | SubtitleData[] | null;
|
|
|
|
| 57 |
clear_status: any;
|
| 58 |
close_stream: any;
|
| 59 |
edit: any;
|
| 60 |
+
custom_button_click: { id: number };
|
| 61 |
}
|
6.2.0/audio/static/StaticAudio.svelte
CHANGED
|
@@ -8,6 +8,7 @@
|
|
| 8 |
DownloadLink,
|
| 9 |
IconButtonWrapper
|
| 10 |
} from "@gradio/atoms";
|
|
|
|
| 11 |
import { Download, Music } from "@gradio/icons";
|
| 12 |
import type { I18nFormatter } from "@gradio/utils";
|
| 13 |
import AudioPlayer from "../player/AudioPlayer.svelte";
|
|
@@ -20,7 +21,8 @@
|
|
| 20 |
export let subtitles: null | FileData | SubtitleData[] = null;
|
| 21 |
export let label: string;
|
| 22 |
export let show_label = true;
|
| 23 |
-
export let buttons: string[] | null = null;
|
|
|
|
| 24 |
export let i18n: I18nFormatter;
|
| 25 |
export let waveform_settings: Record<string, any> = {};
|
| 26 |
export let waveform_options: WaveformOptions = {
|
|
@@ -41,6 +43,9 @@
|
|
| 41 |
}>();
|
| 42 |
|
| 43 |
$: value && dispatch("change", value);
|
|
|
|
|
|
|
|
|
|
| 44 |
</script>
|
| 45 |
|
| 46 |
<BlockLabel
|
|
@@ -56,8 +61,10 @@
|
|
| 56 |
{:else}
|
| 57 |
<IconButtonWrapper
|
| 58 |
display_top_corner={display_icon_button_wrapper_top_corner}
|
|
|
|
|
|
|
| 59 |
>
|
| 60 |
-
{#if
|
| 61 |
<DownloadLink
|
| 62 |
href={value.is_stream
|
| 63 |
? value.url?.replace("playlist.m3u8", "playlist-file")
|
|
@@ -67,7 +74,7 @@
|
|
| 67 |
<IconButton Icon={Download} label={i18n("common.download")} />
|
| 68 |
</DownloadLink>
|
| 69 |
{/if}
|
| 70 |
-
{#if
|
| 71 |
<ShareButton
|
| 72 |
{i18n}
|
| 73 |
on:error
|
|
|
|
| 8 |
DownloadLink,
|
| 9 |
IconButtonWrapper
|
| 10 |
} from "@gradio/atoms";
|
| 11 |
+
import type { CustomButton as CustomButtonType } from "@gradio/utils";
|
| 12 |
import { Download, Music } from "@gradio/icons";
|
| 13 |
import type { I18nFormatter } from "@gradio/utils";
|
| 14 |
import AudioPlayer from "../player/AudioPlayer.svelte";
|
|
|
|
| 21 |
export let subtitles: null | FileData | SubtitleData[] = null;
|
| 22 |
export let label: string;
|
| 23 |
export let show_label = true;
|
| 24 |
+
export let buttons: (string | CustomButtonType)[] | null = null;
|
| 25 |
+
export let on_custom_button_click: ((id: number) => void) | null = null;
|
| 26 |
export let i18n: I18nFormatter;
|
| 27 |
export let waveform_settings: Record<string, any> = {};
|
| 28 |
export let waveform_options: WaveformOptions = {
|
|
|
|
| 43 |
}>();
|
| 44 |
|
| 45 |
$: value && dispatch("change", value);
|
| 46 |
+
|
| 47 |
+
$: buttons_to_render =
|
| 48 |
+
buttons && buttons.length > 0 ? buttons : ["download", "share"];
|
| 49 |
</script>
|
| 50 |
|
| 51 |
<BlockLabel
|
|
|
|
| 61 |
{:else}
|
| 62 |
<IconButtonWrapper
|
| 63 |
display_top_corner={display_icon_button_wrapper_top_corner}
|
| 64 |
+
buttons={buttons_to_render}
|
| 65 |
+
{on_custom_button_click}
|
| 66 |
>
|
| 67 |
+
{#if buttons_to_render.some((btn) => typeof btn === "string" && btn === "download")}
|
| 68 |
<DownloadLink
|
| 69 |
href={value.is_stream
|
| 70 |
? value.url?.replace("playlist.m3u8", "playlist-file")
|
|
|
|
| 74 |
<IconButton Icon={Download} label={i18n("common.download")} />
|
| 75 |
</DownloadLink>
|
| 76 |
{/if}
|
| 77 |
+
{#if buttons_to_render.some((btn) => typeof btn === "string" && btn === "share")}
|
| 78 |
<ShareButton
|
| 79 |
{i18n}
|
| 80 |
on:error
|