diff --git a/client/src/hooks/useServerStream.ts b/client/src/hooks/useServerStream.ts index 32d339357f..09ee440f63 100644 --- a/client/src/hooks/useServerStream.ts +++ b/client/src/hooks/useServerStream.ts @@ -3,6 +3,7 @@ import { useResetRecoilState, useSetRecoilState } from 'recoil'; import { SSE, createPayload, tMessageSchema, tConversationSchema } from 'librechat-data-provider'; import type { TResPlugin, TMessage, TConversation, TSubmission } from 'librechat-data-provider'; import { useAuthContext } from '~/hooks/AuthContext'; +import useSpeechSynthesis from '../Messages/SpeechSynthesis'; import store from '~/store'; type TResData = { @@ -20,6 +21,7 @@ export default function useServerStream(submission: TSubmission | null) { const setConversation = useSetRecoilState(store.conversation); const resetLatestMessage = useResetRecoilState(store.latestMessage); const { token } = useAuthContext(); + const { synthesizeSpeech } = useSpeechSynthesis(); const { refreshConversations } = store.useConversations(); @@ -226,6 +228,9 @@ export default function useServerStream(submission: TSubmission | null) { const { plugins } = data; finalHandler(data, { ...submission, plugins, message }); console.log('final', data); + if (data.responseMessage.text) { + synthesizeSpeech(data.responseMessage.text); + } } if (data.created) { message = {