Sinua
Connect your appVoice

LiveKit

Follow a LiveKit agent: pass your connected room, and the visual tracks the agent's state and voice.

If your app already uses LiveKit, connect the visual to the room you have. The source finds the agent participant, follows its state attribute (lk.agent.state, the same names Sinua uses), and measures the agent's audio track for the level and bands. Pass a room you've already connected, and no credential passes through Sinua. Or let the source join itself with a URL and an access token from your backend: new LiveKitVoiceSource({ url, token }) on the web, LiveKitVoiceSource(url:token:) on iOS, LiveKitVoiceSource.owned(context, url, token) on Android.

livekit-web.ts
// npm i livekit-client (an optional peer: only apps using LiveKit install it)
import { Room } from "livekit-client";
import { LiveKitVoiceSource } from "@sinua/voice/livekit";

// The source joins with your backend's access token and publishes the mic. The agent's
// state comes from its `lk.agent.state` attribute (LiveKit Agents set it).
export async function liveKitVoice() {
  const { url, token } = await (await fetch("/api/livekit-token")).json();
  return new LiveKitVoiceSource({ url, token });
}

// Already have a Room (e.g. from @livekit/components-react)? Pass it; you keep ownership.
export const fromRoom = (room: Room) => new LiveKitVoiceSource({ room });

Packages

PlatformPackage
WebLiveKitVoiceSource from @sinua/voice/livekit (install livekit-client alongside)
iOSSinuaLiveKit (a separate Swift package, pulls client-sdk-swift)
Android:sinua-livekit (pulls livekit-android)

Good to know

  • The state comes from LiveKit Agents. Agents built with LiveKit Agents set lk.agent.state. If your agent doesn't, the source falls back to the audio: the agent is speaking while its track is loud.
  • Your room stays yours. When you pass a room, the source never disconnects it. It waits up to 20 seconds for an agent to join.
  • Say where the audio goes. Publishing the microphone sends the user's voice to your LiveKit server and the agent in the room. Your iOS purpose string (NSMicrophoneUsageDescription) and, on Android, the explanation you show before the RECORD_AUDIO prompt (the system prompt carries no app text) should say so. App Store review expects the purpose string to explain the use.
  • livekit-client is an optional peer on the web. Install it yourself, and only apps that use LiveKit pull it in.

On this page