Hook
useInflectionVoice
Voice state and controls: hold-to-talk, live transcript, and starting or stopping the realtime voice channel.
Install
npm i @inflection/sdk-react # or: bun add @inflection/sdk-reactA package, not a copy: this is protocol logic, so fixes reach you without re-copying files.
Usage
import { useInflectionVoice } from "@inflection/sdk-react"
function HoldToTalk() {
const { listening, transcript, listen, stopListening } = useInflectionVoice()
return (
<button
onPointerDown={listen}
onPointerUp={stopListening}
aria-label={listening ? "Listening" : "Hold to talk"}
>
{listening ? transcript || "Listening…" : "Hold to talk"}
</button>
)
}Returns
| Name | Type | Description |
|---|---|---|
| voiceOn | boolean | The realtime voice channel is up. |
| listening | boolean | The mic is open. |
| transcript | string | What has been heard so far. |
| listen | () => Promise<void> | Open the mic. |
| stopListening | () => Promise<void> | Close it and submit the turn. |
| startVoice | () => void | Bring the voice channel up. |
| stopVoice | () => void | Take it down. |