feat: Supports pronunciation while outputting text #2088 (#2227)

### What problem does this PR solve?

feat: Supports pronunciation while outputting text #2088

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
balibabu
2024-09-03 19:47:50 +08:00
committed by GitHub
parent 87a998e9e5
commit 07de36ec86
7 changed files with 68 additions and 8 deletions

View File

@ -52,7 +52,7 @@ export const useRemoveMessage = (
return { onRemoveMessage, loading };
};
export const useSpeech = (content: string) => {
export const useSpeech = (content: string, audioBinary?: string) => {
const ref = useRef<HTMLAudioElement>(null);
const { read } = useSpeechWithSse();
const player = useRef<SpeechPlayer>();
@ -94,6 +94,15 @@ export const useSpeech = (content: string) => {
}
}, [setIsPlaying, speech, isPlaying, pause]);
// useEffect(() => {
// if (audioBinary) {
// const units = hexStringToUint8Array(audioBinary);
// if (units) {
// player.current?.feed(units);
// }
// }
// }, [audioBinary]);
useEffect(() => {
initialize();
}, [initialize]);