Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
abidlabs committed Jan 22, 2025
1 parent 008455f commit 00f3622
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
4 changes: 3 additions & 1 deletion gradio/components/audio.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,9 @@ def __init__(
else:
self.waveform_options = waveform_options
if self.waveform_options.show_controls is None:
self.waveform_options.show_controls = not self.waveform_options.show_recording_waveform
self.waveform_options.show_controls = (
not self.waveform_options.show_recording_waveform
)
self.min_length = min_length
self.max_length = max_length
self.recording = recording
Expand Down
5 changes: 4 additions & 1 deletion js/audio/Index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
export let show_download_button: boolean;
export let show_share_button = false;
export let editable = true;
export let waveform_options: WaveformOptions = {};
export let waveform_options: WaveformOptions = {
show_recording_waveform: true,
show_controls: false
};
export let pending: boolean;
export let streaming: boolean;
export let stream_every: number;
Expand Down
16 changes: 8 additions & 8 deletions js/audio/player/AudioPlayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
}>();
$: use_default_controls = waveform_options.show_controls || value?.is_stream;
$: use_waveform =
waveform_options.show_recording_waveform && !value?.is_stream;
const create_waveform = (): void => {
waveform = WaveSurfer.create({
Expand All @@ -68,11 +70,7 @@
});
};
$: if (
!use_default_controls &&
container !== undefined &&
container !== null
) {
$: if (!value?.is_stream && container !== undefined && container !== null) {
if (waveform !== undefined) waveform.destroy();
container.innerHTML = "";
create_waveform();
Expand Down Expand Up @@ -146,7 +144,9 @@
if (waveform_options.show_recording_waveform) {
waveform?.load(resolved_src);
} else if (waveform_options.show_controls) {
audio_player.src = resolved_src;
if (audio_player) {
audio_player.src = resolved_src;
}
}
});
}
Expand Down Expand Up @@ -213,7 +213,7 @@

<audio
class="standard-player"
class:hidden={!use_default_controls}
class:hidden={use_waveform}
controls
autoplay={waveform_settings.autoplay}
on:load
Expand All @@ -225,7 +225,7 @@
<Empty size="small">
<Music />
</Empty>
{:else if !value.is_stream && waveform_options.show_recording_waveform}
{:else if use_waveform}
<div
class="component-wrapper"
data-testid={label ? "waveform-" + label : "unlabelled-audio"}
Expand Down
2 changes: 1 addition & 1 deletion js/chatbot/shared/Component.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
{i18n}
label=""
waveform_settings={{ autoplay: props.autoplay }}
waveform_options={{}}
waveform_options={{ ...props.waveform_options }}
show_download_button={allow_file_downloads}
{display_icon_button_wrapper_top_corner}
on:load
Expand Down

0 comments on commit 00f3622

Please sign in to comment.