mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: Supports text output and sound output #1877 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -3,6 +3,7 @@ import { useSetModalState } from '@/hooks/common-hooks';
|
||||
import { IRemoveMessageById, useSpeechWithSse } from '@/hooks/logic-hooks';
|
||||
import { IFeedbackRequestBody } from '@/interfaces/request/chat';
|
||||
import { getMessagePureId } from '@/utils/chat';
|
||||
import { hexStringToUint8Array } from '@/utils/common-util';
|
||||
import { SpeechPlayer } from 'openai-speech-stream-player';
|
||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||
|
||||
@ -94,14 +95,14 @@ export const useSpeech = (content: string, audioBinary?: string) => {
|
||||
}
|
||||
}, [setIsPlaying, speech, isPlaying, pause]);
|
||||
|
||||
// useEffect(() => {
|
||||
// if (audioBinary) {
|
||||
// const units = hexStringToUint8Array(audioBinary);
|
||||
// if (units) {
|
||||
// player.current?.feed(units);
|
||||
// }
|
||||
// }
|
||||
// }, [audioBinary]);
|
||||
useEffect(() => {
|
||||
if (audioBinary) {
|
||||
const units = hexStringToUint8Array(audioBinary);
|
||||
if (units) {
|
||||
player.current?.feed(units);
|
||||
}
|
||||
}
|
||||
}, [audioBinary]);
|
||||
|
||||
useEffect(() => {
|
||||
initialize();
|
||||
|
||||
Reference in New Issue
Block a user