From 942d56b33d9b03cc439e85e36c869f1480d28909 Mon Sep 17 00:00:00 2001 From: Archer <545436317@qq.com> Date: Thu, 10 Oct 2024 12:24:07 +0800 Subject: [PATCH] IOS safari whisper support (#2870) * fix: variables check * remove log * perf: safari whisper * feat: comment * perf: connetion check * doc --- .../zh-cn/docs/development/upgrading/4811.md | 13 +++++++------ .../service/core/workflow/dispatch/tools/http468.ts | 1 + .../chat/ChatContainer/ChatBox/Input/ChatInput.tsx | 2 +- .../Flow/nodes/render/Handle/ToolHandle.tsx | 5 +++-- projects/app/src/web/common/hooks/useSpeech.ts | 11 +++++++---- 5 files changed, 19 insertions(+), 13 deletions(-) diff --git a/docSite/content/zh-cn/docs/development/upgrading/4811.md b/docSite/content/zh-cn/docs/development/upgrading/4811.md index f29be1c909d..fa4e75ea9e6 100644 --- a/docSite/content/zh-cn/docs/development/upgrading/4811.md +++ b/docSite/content/zh-cn/docs/development/upgrading/4811.md @@ -94,7 +94,7 @@ curl --location --request POST 'https://{{host}}/api/admin/init/4811' \ --header 'Content-Type: application/json' ``` -会初始化成员组。 +会初始化团队成员组。 ## V4.8.11 更新说明 @@ -120,8 +120,9 @@ curl --location --request POST 'https://{{host}}/api/admin/init/4811' \ 20. 修复 - 工作流工具调用中修改全局变量后,无法传递到后续流程。 21. 优化 - 流输出,切换浏览器 Tab 后仍可以继续输出。 22. 优化 - 完善外部文件知识库相关 API -23. 修复 - 知识库选择权限问题。 -24. 修复 - 空 chatId 发起对话,首轮携带用户选择时会异常。 -25. 修复 - createDataset 接口,intro 为赋值。 -26. 修复 - 对话框渲染性能问题。 -27. 修复 - 工具调用历史记录存储不正确。 +23. 优化 - IOS Safari 浏览器,语音输入不准确。 +24. 修复 - 知识库选择权限问题。 +25. 修复 - 空 chatId 发起对话,首轮携带用户选择时会异常。 +26. 修复 - createDataset 接口,intro 为赋值。 +27. 修复 - 对话框渲染性能问题。 +28. 修复 - 工具调用历史记录存储不正确。 diff --git a/packages/service/core/workflow/dispatch/tools/http468.ts b/packages/service/core/workflow/dispatch/tools/http468.ts index baf65faf09a..6b52e384ab1 100644 --- a/packages/service/core/workflow/dispatch/tools/http468.ts +++ b/packages/service/core/workflow/dispatch/tools/http468.ts @@ -184,6 +184,7 @@ export const dispatchHttp468Request = async (props: HttpRequestProps): Promise = (() => { if (requestBody instanceof FormData || requestBody instanceof URLSearchParams) { return Object.fromEntries(requestBody); diff --git a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx index 3cfc8b265d0..23bea55aa4b 100644 --- a/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx +++ b/projects/app/src/components/core/chat/ChatContainer/ChatBox/Input/ChatInput.tsx @@ -286,7 +286,7 @@ const ChatInput = ({ /> {/* voice-input */} - {whisperConfig.open && !havInput && !isChatting && !!whisperModel && ( + {whisperConfig.open && !inputValue && !isChatting && !!whisperModel && ( <> { const connected = edges.some((edge) => edge.target === nodeId && edge.targetHandle === handleId); // if top handle is connected, return null - const showHandle = - connected || (show && connectingEdge?.handleId === NodeOutputKeyEnum.selectedTools); + const showHandle = connectingEdge + ? show && connectingEdge.handleId === NodeOutputKeyEnum.selectedTools + : connected; const Render = useMemo(() => { return ( diff --git a/projects/app/src/web/common/hooks/useSpeech.ts b/projects/app/src/web/common/hooks/useSpeech.ts index fd9f6694aae..8603a4e2502 100644 --- a/projects/app/src/web/common/hooks/useSpeech.ts +++ b/projects/app/src/web/common/hooks/useSpeech.ts @@ -85,10 +85,13 @@ export const useSpeech = (props?: OutLinkChatAuthProps & { appId?: string }) => if (!cancelWhisperSignal.current) { const formData = new FormData(); let options = {}; - if (MediaRecorder.isTypeSupported('audio/webm')) { - options = { type: 'audio/webm' }; - } else if (MediaRecorder.isTypeSupported('video/mp3')) { - options = { type: 'video/mp3' }; + + if (MediaRecorder.isTypeSupported('video/webm; codecs=vp9')) { + options = { mimeType: 'video/webm; codecs=vp9' }; + } else if (MediaRecorder.isTypeSupported('video/webm')) { + options = { type: 'video/webm' }; + } else if (MediaRecorder.isTypeSupported('video/mp4')) { + options = { mimeType: 'video/mp4', videoBitsPerSecond: 100000 }; } else { console.error('no suitable mimetype found for this device'); }