observer / src /lib /blobToBase64Uri.ts
jbilcke-hf's picture
jbilcke-hf HF staff
add support for whisper-turbo (base)
7249a2e
raw
history blame contribute delete
485 Bytes
export function blobToBase64Uri(blob?: Blob): Promise<string> {
return new Promise((resolve, reject) => {
if (!blob || typeof window === "undefined" || !window.FileReader) {
resolve("")
return
}
const reader = new window.FileReader()
reader.readAsDataURL(blob)
reader.onloadend = () => {
resolve(`${reader.result || ""}`)
}
reader.onerror = () => {
// reject("error while converting blob to base64")
resolve("")
}
})
}