useTranscriptions
function useTranscriptions(opts?): Segment[];Defined in: packages/react/src/hooks/track/useTranscriptions.ts:31
The transcript segments for the current <VoiceRoom>. Pass { role } to filter
to just the user's or agent's turns. (the upstream API returns TextStreamData[]; this
returns Valora Segment[] — that shape is beta and may drift.)
Parameters
| Parameter | Type |
|---|---|
opts? | { role?: "user" | "agent"; } |
opts.role? | "user" | "agent" |
Returns
Segment[]
Example
// Basic — render every transcript segment.
const segments = useTranscriptions();
return <>{segments.map((s) => <p key={s.id}>{s.text}</p>)}</>;
// Advanced — split user and agent turns in a room transcript.
function TranscriptPanel() {
const userSegments = useTranscriptions({ role: "user" });
const agentSegments = useTranscriptions({ role: "agent" });
return (
<VoiceRoom agent={agent}>
<section>{userSegments.map((s) => <p key={s.id}>{s.text}</p>)}</section>
<section>{agentSegments.map((s) => <p key={s.id}>{s.text}</p>)}</section>
</VoiceRoom>
);
}