The useVoiceChatState hook is designed for voice-based interaction with agents in your React application.

Arguments

client
Client
required

Your Scoopika client, initialized using @scoopika/client.

agent
Agent
required

Your Scoopika agent, initialized using @scoopika/client.

options
Object

Configuration options for the state, this can include all the options available to useChatState, plus:

  • auto_play_audio: Automatically play the agent’s audio response in real-time (defaults to true).
  • agent_voice: An object defining the settings for the agent voice player. See agent voice options for more information.

Agent voice options

These options are passed to the state options under agent_voice. If not provided, the agent’s voice will not be played.

audio
HTMLAudioElement | string
required

The audio element that the agent voice player will use to play the audio response.

You can provide the element itself or its ID. Typically, you’ll create an audio element specifically for the agent voice player and pass its ID.

canvas
HTMLCanvasElement | string

An HTML canvas element or its ID. If provided, the agent’s voice will be visualized in real-time.

The visualized voice will be drawn on the canvas. The visualizer is similar to the one shown in the GPT4-o promotion videos and is the same one used in the Scoopika playground:

wave_color
string

The color of the visualizer wave. If not provided, it defaults to black.