Skip to content

Commit a1f1f4d

Browse files
authored
Merge branch 'main' into issue/h2oai#2047
2 parents f6e4d0d + 3f94a16 commit a1f1f4d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

ui/src/.wavegen

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ui.ts
22
theme.ts
3-
defs.ts
3+
defs.ts
4+
core.ts

ui/src/audio_annotator.tsx

+11-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ const
7777
{ key: 1.5, text: '1.5x' },
7878
{ key: 2, text: '2x' },
7979
],
80+
audioMimeTypes = {
81+
mp3: 'audio/mpeg',
82+
wav: 'audio/wav',
83+
ogg: 'audio/ogg',
84+
flac: 'audio/flac',
85+
aac: 'audio/aac',
86+
m4a: 'audio/mp4',
87+
},
8088
// Love ya Safari.
8189
promisifyDecodeAudioData = (audioContext: AudioContext, audioData: ArrayBuffer) => new Promise<AudioBuffer>((resolve, reject) => {
8290
audioContext.decodeAudioData(audioData, resolve, reject)
@@ -125,9 +133,11 @@ export const XAudioAnnotator = ({ model }: { model: AudioAnnotator }) => {
125133
setErrMsg('Could not download audio file.')
126134
return
127135
}
136+
const ext = model.path.split('.').pop()?.toLowerCase() as keyof typeof audioMimeTypes
137+
const type = audioMimeTypes[ext] || 'audio/mpeg'
128138
// Store the URL into the ref so that it can be revoked on destroy and mem leak prevented.
129139
// Safari needs Blob type to be specified, doesn't need to match the real sound format.
130-
fetchedAudioUrlRef.current = URL.createObjectURL(new Blob([arrBuffer], { type: 'audio/mpeg' }))
140+
fetchedAudioUrlRef.current = URL.createObjectURL(new Blob([arrBuffer], { type }))
131141
// Do not set src directly within HTML to prevent double fetching.
132142
audioRef.current.src = fetchedAudioUrlRef.current
133143

0 commit comments

Comments
 (0)