diff --git a/packages/embed-react/package.json b/packages/embed-react/package.json index 87dc1f4..6b33e54 100644 --- a/packages/embed-react/package.json +++ b/packages/embed-react/package.json @@ -1,6 +1,6 @@ { "name": "@humeai/voice-embed-react", - "version": "0.1.19-beta.1", + "version": "0.1.19-beta.2", "description": "", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/embed/package.json b/packages/embed/package.json index 64f3a66..178b40d 100644 --- a/packages/embed/package.json +++ b/packages/embed/package.json @@ -1,6 +1,6 @@ { "name": "@humeai/voice-embed", - "version": "0.1.19-beta.1", + "version": "0.1.19-beta.2", "description": "", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/react/README.md b/packages/react/README.md index 899fc4d..a328133 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -107,6 +107,10 @@ See a complete list of props accepted by `VoiceProvider` below: (_Optional_) Callback function to invoke upon receiving a ToolCallMessage through the web socket. It will send the string returned as a the content of a ToolResponseMessage. This is where you should add logic that handles your custom tool calls. +#### `onAudioReceived?`: (message: AudioOutputMessage) => void + +(_Optional_) Callback function to invoke when an audio output message is received from the websocket. + #### `onAudioStart?`: (clipId: string) => void (_Optional_) Callback function to invoke when an audio clip from the assistant starts playing. diff --git a/packages/react/package.json b/packages/react/package.json index c9cdca0..cdca86d 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -1,6 +1,6 @@ { "name": "@humeai/voice-react", - "version": "0.1.19-beta.1", + "version": "0.1.19-beta.2", "description": "", "main": "./dist/index.js", "module": "./dist/index.mjs", diff --git a/packages/react/src/lib/VoiceProvider.tsx b/packages/react/src/lib/VoiceProvider.tsx index dcb882b..e92962b 100644 --- a/packages/react/src/lib/VoiceProvider.tsx +++ b/packages/react/src/lib/VoiceProvider.tsx @@ -98,6 +98,7 @@ export type VoiceProviderProps = PropsWithChildren & { onOpen?: () => void; onClose?: Hume.empathicVoice.chat.ChatSocket.EventHandlers['close']; onToolCall?: ToolCallHandler; + onAudioReceived?: (audioOutputMessage: AudioOutputMessage) => void; onAudioStart?: (clipId: string) => void; onAudioEnd?: (clipId: string) => void; onInterruption?: ( @@ -159,6 +160,9 @@ export const VoiceProvider: FC = ({ const onMessage = useRef(props.onMessage ?? noop); onMessage.current = props.onMessage ?? noop; + const onAudioReceived = useRef(props.onAudioReceived ?? noop); + onAudioReceived.current = props.onAudioReceived ?? noop; + const onAudioStart = useRef(props.onAudioStart ?? noop); onAudioStart.current = props.onAudioStart ?? noop; @@ -212,6 +216,7 @@ export const VoiceProvider: FC = ({ const client = useVoiceClient({ onAudioMessage: (message: AudioOutputMessage) => { player.addToQueue(message); + onAudioReceived.current(message); }, onMessage: useCallback( (message: JSONMessage) => {