From e268ee56756df387a60fa756035a41cc3cf78040 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Tue, 24 Sep 2024 11:00:47 +0200 Subject: [PATCH] enh: audio/x-m4a support --- backend/open_webui/apps/audio/main.py | 2 +- src/lib/components/chat/MessageInput.svelte | 2 +- src/lib/components/workspace/Documents.svelte | 2 +- src/lib/constants.ts | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/backend/open_webui/apps/audio/main.py b/backend/open_webui/apps/audio/main.py index 0eee533bd..a1e6e94fa 100644 --- a/backend/open_webui/apps/audio/main.py +++ b/backend/open_webui/apps/audio/main.py @@ -360,7 +360,7 @@ def transcribe( ): log.info(f"file.content_type: {file.content_type}") - if file.content_type not in ["audio/mpeg", "audio/wav", "audio/ogg"]: + if file.content_type not in ["audio/mpeg", "audio/wav", "audio/ogg", "audio/x-m4a"]: raise HTTPException( status_code=status.HTTP_400_BAD_REQUEST, detail=ERROR_MESSAGES.FILE_NOT_SUPPORTED, diff --git a/src/lib/components/chat/MessageInput.svelte b/src/lib/components/chat/MessageInput.svelte index f474b755b..ea6b0aec8 100644 --- a/src/lib/components/chat/MessageInput.svelte +++ b/src/lib/components/chat/MessageInput.svelte @@ -107,7 +107,7 @@ files = [...files, fileItem]; // Check if the file is an audio file and transcribe/convert it to text file - if (['audio/mpeg', 'audio/wav', 'audio/ogg'].includes(file['type'])) { + if (['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/x-m4a'].includes(file['type'])) { const res = await transcribeAudio(localStorage.token, file).catch((error) => { toast.error(error); return null; diff --git a/src/lib/components/workspace/Documents.svelte b/src/lib/components/workspace/Documents.svelte index f1e77bddd..38f46f745 100644 --- a/src/lib/components/workspace/Documents.svelte +++ b/src/lib/components/workspace/Documents.svelte @@ -55,7 +55,7 @@ const uploadDoc = async (file, tags?: object) => { console.log(file); // Check if the file is an audio file and transcribe/convert it to text file - if (['audio/mpeg', 'audio/wav', 'audio/ogg'].includes(file['type'])) { + if (['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/x-m4a'].includes(file['type'])) { const transcribeRes = await transcribeAudio(localStorage.token, file).catch((error) => { toast.error(error); return null; diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 5fc1e7b19..ad7b5c29e 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -31,7 +31,9 @@ export const SUPPORTED_FILE_TYPE = [ 'application/x-javascript', 'text/markdown', 'audio/mpeg', - 'audio/wav' + 'audio/wav', + 'audio/ogg', + 'audio/x-m4a' ]; export const SUPPORTED_FILE_EXTENSIONS = [