mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-02 18:39:06 +08:00
添加了 TTS 相关服务并更新了设置
This commit is contained in:
parent
8e56f8774f
commit
d5cededd8b
@ -76,7 +76,7 @@ const DraggableVoiceCallWindow: React.FC<Props> = ({
|
|||||||
// 启动语音通话
|
// 启动语音通话
|
||||||
await VoiceCallService.startCall({
|
await VoiceCallService.startCall({
|
||||||
onTranscript: (text) => setTranscript(text),
|
onTranscript: (text) => setTranscript(text),
|
||||||
onResponse: (_) => {
|
onResponse: () => {
|
||||||
// 这里不设置response,因为响应会显示在聊天界面中
|
// 这里不设置response,因为响应会显示在聊天界面中
|
||||||
},
|
},
|
||||||
onListeningStateChange: setIsListening,
|
onListeningStateChange: setIsListening,
|
||||||
@ -118,7 +118,7 @@ const DraggableVoiceCallWindow: React.FC<Props> = ({
|
|||||||
// 移除事件监听器
|
// 移除事件监听器
|
||||||
window.removeEventListener('tts-state-change', handleTTSStateChange as EventListener)
|
window.removeEventListener('tts-state-change', handleTTSStateChange as EventListener)
|
||||||
}
|
}
|
||||||
}, [visible, t])
|
}, [visible, t, dispatch, onClose])
|
||||||
|
|
||||||
// 拖拽相关处理
|
// 拖拽相关处理
|
||||||
const handleDragStart = (e: React.MouseEvent) => {
|
const handleDragStart = (e: React.MouseEvent) => {
|
||||||
|
|||||||
@ -29,6 +29,11 @@ const VoiceCallModal: React.FC<Props> = ({ visible, onClose }) => {
|
|||||||
const [isRecording, setIsRecording] = useState(false);
|
const [isRecording, setIsRecording] = useState(false);
|
||||||
const [isProcessing, setIsProcessing] = useState(false);
|
const [isProcessing, setIsProcessing] = useState(false);
|
||||||
|
|
||||||
|
const handleClose = () => {
|
||||||
|
VoiceCallService.endCall();
|
||||||
|
onClose();
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const startVoiceCall = async () => {
|
const startVoiceCall = async () => {
|
||||||
try {
|
try {
|
||||||
@ -78,12 +83,7 @@ const VoiceCallModal: React.FC<Props> = ({ visible, onClose }) => {
|
|||||||
// 移除事件监听器
|
// 移除事件监听器
|
||||||
window.removeEventListener('tts-state-change', handleTTSStateChange as EventListener);
|
window.removeEventListener('tts-state-change', handleTTSStateChange as EventListener);
|
||||||
};
|
};
|
||||||
}, [visible, t]);
|
}, [visible, t, handleClose]);
|
||||||
|
|
||||||
const handleClose = () => {
|
|
||||||
VoiceCallService.endCall();
|
|
||||||
onClose();
|
|
||||||
};
|
|
||||||
|
|
||||||
const toggleMute = () => {
|
const toggleMute = () => {
|
||||||
const newMuteState = !isMuted;
|
const newMuteState = !isMuted;
|
||||||
|
|||||||
@ -49,7 +49,7 @@ const VoiceCallWindow: React.FC = () => {
|
|||||||
// 启动语音通话
|
// 启动语音通话
|
||||||
await VoiceCallService.startCall({
|
await VoiceCallService.startCall({
|
||||||
onTranscript: (text) => setTranscript(text),
|
onTranscript: (text) => setTranscript(text),
|
||||||
onResponse: (_) => {
|
onResponse: () => {
|
||||||
// 这里不设置response,因为响应会显示在聊天界面中
|
// 这里不设置response,因为响应会显示在聊天界面中
|
||||||
},
|
},
|
||||||
onListeningStateChange: setIsListening,
|
onListeningStateChange: setIsListening,
|
||||||
|
|||||||
@ -163,7 +163,7 @@ export class TTSTextFilter {
|
|||||||
text = text.replace(/[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu, '')
|
text = text.replace(/[\u{1F300}-\u{1F5FF}\u{1F600}-\u{1F64F}\u{1F680}-\u{1F6FF}\u{1F700}-\u{1F77F}\u{1F780}-\u{1F7FF}\u{1F800}-\u{1F8FF}\u{1F900}-\u{1F9FF}\u{1FA00}-\u{1FA6F}\u{1FA70}-\u{1FAFF}\u{2600}-\u{26FF}\u{2700}-\u{27BF}]/gu, '')
|
||||||
|
|
||||||
// 过滤符号表情,如 :) :( :D 等
|
// 过滤符号表情,如 :) :( :D 等
|
||||||
text = text.replace(/[:;][\-']?[\)\(DOPdop\|\\\/\{\}\[\]\*]+/g, '')
|
text = text.replace(/[:;][-']?[)(DOPdop|\/{\}\[\]\*]+/g, '')
|
||||||
|
|
||||||
// 过滤文本表情,如 (smile) (sad) 等
|
// 过滤文本表情,如 (smile) (sad) 等
|
||||||
text = text.replace(/\([a-zA-Z]+\)/g, '')
|
text = text.replace(/\([a-zA-Z]+\)/g, '')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user