mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-18 09:20:15 +01:00
🗣️ fix(tts): Add Text Parser for Message Content Parts (#2840)
* fix: manual TTS trigger for message content parts * ci(streamAudio): processChunks test
This commit is contained in:
parent
dc1778b11f
commit
8e66683577
4 changed files with 52 additions and 27 deletions
|
|
@ -1,11 +1,13 @@
|
|||
import { useRef } from 'react';
|
||||
import useTextToSpeechBrowser from './useTextToSpeechBrowser';
|
||||
import { parseTextParts } from 'librechat-data-provider';
|
||||
import type { TMessageContentParts } from 'librechat-data-provider';
|
||||
import useTextToSpeechExternal from './useTextToSpeechExternal';
|
||||
import useTextToSpeechBrowser from './useTextToSpeechBrowser';
|
||||
import { usePauseGlobalAudio } from '../Audio';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import store from '~/store';
|
||||
|
||||
const useTextToSpeech = (message: string, isLast: boolean, index = 0) => {
|
||||
const useTextToSpeech = (message: string | TMessageContentParts[], isLast: boolean, index = 0) => {
|
||||
const [endpointTTS] = useRecoilState<string>(store.endpointTTS);
|
||||
const useExternalTextToSpeech = endpointTTS === 'external';
|
||||
|
||||
|
|
@ -34,7 +36,8 @@ const useTextToSpeech = (message: string, isLast: boolean, index = 0) => {
|
|||
isMouseDownRef.current = true;
|
||||
timerRef.current = window.setTimeout(() => {
|
||||
if (isMouseDownRef.current) {
|
||||
generateSpeech(message, true);
|
||||
const parsedMessage = typeof message === 'string' ? message : parseTextParts(message);
|
||||
generateSpeech(parsedMessage, true);
|
||||
}
|
||||
}, 1000);
|
||||
};
|
||||
|
|
@ -51,7 +54,8 @@ const useTextToSpeech = (message: string, isLast: boolean, index = 0) => {
|
|||
cancelSpeech();
|
||||
pauseGlobalAudio();
|
||||
} else {
|
||||
generateSpeech(message, false);
|
||||
const parsedMessage = typeof message === 'string' ? message : parseTextParts(message);
|
||||
generateSpeech(parsedMessage, false);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue