Skip to content

Commit 071c547

Browse files
author
Mishig Davaadorj
authored
Minor fixes for audio widgets (#515)
* Style aud-to-aud widget output better * Rm audio autoplay examples widget * Lint * Fix audio widget sample select
1 parent aba1f85 commit 071c547

File tree

3 files changed

+10
-33
lines changed

3 files changed

+10
-33
lines changed

widgets/src/lib/InferenceWidget/widgets/AudioClassificationWidget/AudioClassificationWidget.svelte

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
let output: Array<{ label: string; score: number }> = [];
2929
let outputJson: string;
3030
let selectedSampleUrl = "";
31-
let shouldAudioAutoplay = true;
3231
3332
function onRecordStart() {
3433
file = null;
@@ -42,7 +41,6 @@
4241
}
4342
4443
function onSelectFile(updatedFile: Blob | File) {
45-
shouldAudioAutoplay = false;
4644
isRecording = false;
4745
selectedSampleUrl = "";
4846
@@ -125,15 +123,14 @@
125123
}
126124
127125
function applyInputSample(sample: Record<string, any>) {
128-
shouldAudioAutoplay = false;
126+
file = null;
129127
filename = sample.example_title;
130128
fileUrl = sample.src;
131129
selectedSampleUrl = sample.src;
132130
getOutput();
133131
}
134132
135133
function previewInputSample(sample: Record<string, any>) {
136-
shouldAudioAutoplay = true;
137134
filename = sample.example_title;
138135
fileUrl = sample.src;
139136
output = [];
@@ -170,12 +167,7 @@
170167
/>
171168
</div>
172169
{#if fileUrl}
173-
<WidgetAudioTrack
174-
classNames="mt-3"
175-
autoplay={shouldAudioAutoplay}
176-
label={filename}
177-
src={fileUrl}
178-
/>
170+
<WidgetAudioTrack classNames="mt-3" label={filename} src={fileUrl} />
179171
{/if}
180172
<WidgetSubmitBtn
181173
classNames="mt-2"

widgets/src/lib/InferenceWidget/widgets/AudioToAudioWidget/AudioToAudioWidget.svelte

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
let output: AudioItem[] = [];
2828
let outputJson: string;
2929
let selectedSampleUrl = "";
30-
let shouldAudioAutoplay = true;
3130
3231
interface AudioItem {
3332
blob: string;
@@ -48,7 +47,6 @@
4847
}
4948
5049
function onSelectFile(updatedFile: Blob | File) {
51-
shouldAudioAutoplay = false;
5250
isRecording = false;
5351
selectedSampleUrl = "";
5452
if (updatedFile.size !== 0) {
@@ -131,15 +129,14 @@
131129
}
132130
133131
function applyInputSample(sample: Record<string, any>) {
134-
shouldAudioAutoplay = false;
132+
file = null;
135133
filename = sample.example_title;
136134
fileUrl = sample.src;
137135
selectedSampleUrl = sample.src;
138136
getOutput();
139137
}
140138
141139
function previewInputSample(sample: Record<string, any>) {
142-
shouldAudioAutoplay = true;
143140
filename = sample.example_title;
144141
fileUrl = sample.src;
145142
output = [];
@@ -176,12 +173,7 @@
176173
/>
177174
</div>
178175
{#if fileUrl}
179-
<WidgetAudioTrack
180-
classNames="mt-3"
181-
autoplay={shouldAudioAutoplay}
182-
label={filename}
183-
src={fileUrl}
184-
/>
176+
<WidgetAudioTrack classNames="mt-3" label={filename} src={fileUrl} />
185177
{/if}
186178
<WidgetSubmitBtn
187179
classNames="mt-2"
@@ -195,9 +187,10 @@
195187
</svelte:fragment>
196188
<svelte:fragment slot="bottom">
197189
{#each output as item}
198-
<div>{item.label}</div>
199-
:
200-
<WidgetAudioTrack classNames="mt-4" src={item.src} />
190+
<div class="flex items-center mt-2">
191+
<span class="mr-2">{item.label}:</span>
192+
<WidgetAudioTrack classNames="" src={item.src} />
193+
</div>
201194
{/each}
202195
</svelte:fragment>
203196
</WidgetWrapper>

widgets/src/lib/InferenceWidget/widgets/AutomaticSpeechRecognitionWidget/AutomaticSpeechRecognitionWidget.svelte

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
let output = "";
2929
let outputJson: string;
3030
let selectedSampleUrl = "";
31-
let shouldAudioAutoplay = true;
3231
3332
function onRecordStart() {
3433
file = null;
@@ -42,7 +41,6 @@
4241
}
4342
4443
function onSelectFile(updatedFile: Blob | File) {
45-
shouldAudioAutoplay = false;
4644
isRecording = false;
4745
selectedSampleUrl = "";
4846
@@ -114,15 +112,14 @@
114112
}
115113
116114
function applyInputSample(sample: Record<string, any>) {
117-
shouldAudioAutoplay = false;
115+
file = null;
118116
filename = sample.example_title;
119117
fileUrl = sample.src;
120118
selectedSampleUrl = sample.src;
121119
getOutput();
122120
}
123121
124122
function previewInputSample(sample: Record<string, any>) {
125-
shouldAudioAutoplay = true;
126123
filename = sample.example_title;
127124
fileUrl = sample.src;
128125
output = "";
@@ -159,12 +156,7 @@
159156
/>
160157
</div>
161158
{#if fileUrl}
162-
<WidgetAudioTrack
163-
classNames="mt-3"
164-
autoplay={shouldAudioAutoplay}
165-
label={filename}
166-
src={fileUrl}
167-
/>
159+
<WidgetAudioTrack classNames="mt-3" label={filename} src={fileUrl} />
168160
{/if}
169161
<WidgetSubmitBtn
170162
classNames="mt-2"

0 commit comments

Comments
 (0)