Skip to content
This repository has been archived by the owner on Feb 5, 2025. It is now read-only.

improve voice logic #483

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/chat/src/views/VoiceWidget/VoiceWidget.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { VoiceState } from '@/constant/voice.constant';
import { VOICE_STATE } from '@/constant/voice.constant';
import { RuntimeStateAPIContext } from '@/contexts';

import { useVoiceController } from './hooks/use-voice-controller.hook';
import { useVoiceService } from './hooks/use-voice-service.hook';

export const VoiceWidget = () => {
const { assistant, config } = useContext(RuntimeStateAPIContext);
Expand All @@ -15,23 +15,23 @@ export const VoiceWidget = () => {
throw new Error('Voice is not configured in the config');
}

const voiceController = useVoiceController({
const voiceService = useVoiceService({
url: config.voice.url,
userID: config.userID,
assistantID: config.verify.projectID,
accessToken: config.voice.accessToken,
});

useEffect(() => voiceController.onStateUpdate((state) => setState(state)), [voiceController]);
useEffect(() => voiceService.onStateUpdate((state) => setState(state)), [voiceService]);

return (
<VoiceView
state={state}
footer={assistant.common.footerLink}
settings={assistant.voice}
poweredBy={assistant.common.poweredBy}
onEndCall={voiceController.endConversation}
onStartCall={voiceController.startConversation}
onEndCall={voiceService.endConversation}
onStartCall={voiceService.startConversation}
/>
);
};
334 changes: 0 additions & 334 deletions packages/chat/src/views/VoiceWidget/hooks/Voice.controller.ts

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { useCreateConst } from '@/hooks/cache.hook';
import { VoiceService, VoiceServiceOptions } from '../services/voice.service';

interface IUserVoiceService extends VoiceServiceOptions {}

export const useVoiceService = (options: IUserVoiceService) => {
const voiceService = useCreateConst(() => new VoiceService(options));

return voiceService;
};
Loading
Loading