Concat plugin to app (#1799)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
'use client';
|
||||
|
||||
import { useState, useCallback, useEffect, useMemo, useRef } from 'react';
|
||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||
import { getErrText } from '@fastgpt/global/common/error/utils';
|
||||
@@ -21,9 +23,10 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
|
||||
|
||||
// Check whether the voice is supported
|
||||
const hasAudio = (() => {
|
||||
if (typeof window === 'undefined') return false;
|
||||
if (ttsConfig?.type === TTSTypeEnum.none) return false;
|
||||
if (ttsConfig?.type === TTSTypeEnum.model) return true;
|
||||
const voices = window.speechSynthesis?.getVoices?.() || []; // 获取语言包
|
||||
const voices = window?.speechSynthesis?.getVoices?.() || []; // 获取语言包
|
||||
const voice = voices.find((item) => {
|
||||
return item.lang === 'zh-CN' || item.lang === 'zh';
|
||||
});
|
||||
@@ -69,9 +72,9 @@ export const useAudioPlay = (props?: OutLinkChatAuthProps & { ttsConfig?: AppTTS
|
||||
);
|
||||
const playWebAudio = useCallback((text: string) => {
|
||||
// window speech
|
||||
window.speechSynthesis?.cancel();
|
||||
window?.speechSynthesis?.cancel();
|
||||
const msg = new SpeechSynthesisUtterance(text);
|
||||
const voices = window.speechSynthesis?.getVoices?.() || []; // 获取语言包
|
||||
const voices = window?.speechSynthesis?.getVoices?.() || []; // 获取语言包
|
||||
const voice = voices.find((item) => {
|
||||
return item.lang === 'zh-CN';
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user