Standard library · Voice
- The language
- Agents and tools
- Model providers
- The Anthropic API
- Talking agents
- Standard library
- Glossary
- Package docs
- Telemetry
- Robots
- Servers
- Deploying
- tin.ad
- The tin command
- How it works
On this page
Voice
The types a voice agent session uses: its events, audio in and audio out. See the status page for what has been verified with real providers.
All 22 symbols
VoiceEventSessionAudioOutAudioInAudiomicspeakerAudioIn.readAudioOut.playAudioOut.clearAudio.secondsAudio.rateAudio.levelAudio.showtonesilenceSession.saySession.sendSession.nextSession.interruptSession.stopSession.save
VoiceEvent
type VoiceEvent = Connected(string) | Speech(Audio) | Hearing(string) | Heard(string) | Saying(string) | Said(string) | Wrote(string) | CallingTool { name: string, input: string } | ToolReturned { name: string, output: string, ok: bool } | BargedIn | TurnDone | TokensUsed { input: int, output: int } | RestartSoon(int) | Reconnected { reason: string, interrupted: bool } | HungUp(string) What a live session reports, in order. \`s.next()\` waits for the next one.
Session
type Session = { handle: int } One live conversation with a \`voice agent\`, from \`A.open()\`.
AudioOut
type AudioOut = { handle: int } Where sound goes: \`speaker()\`, or a file/pipe given with \`tin run --speaker\`.
AudioIn
type AudioIn = { handle: int } Where sound comes from: \`mic()\`, or a file/pipe given with \`tin run --mic\`.
Audio
type Audio = { handle: int } A piece of sound: 16-bit mono PCM held by the host, not copied into the program's memory.
mic
fn mic(): AudioIn The microphone (or the \`--mic\` file). Needs the \`mic\` capability.
speaker
fn speaker(): AudioOut The speaker (or the \`--speaker\` file). Needs the \`speaker\` capability.
AudioIn.read
fn AudioIn.read(i: AudioIn): Option<Audio> The next chunk of input, or None when the input has ended.
AudioOut.play
fn AudioOut.play(o: AudioOut, a: Audio) No summary yet; the signature is the whole description.
AudioOut.clear
fn AudioOut.clear(o: AudioOut) Drop everything queued but not yet played (what a barge-in does).
Audio.seconds
fn Audio.seconds(a: Audio): float No summary yet; the signature is the whole description.
Audio.rate
fn Audio.rate(a: Audio): int No summary yet; the signature is the whole description.
Audio.level
fn Audio.level(a: Audio): float Loudness from 0.0 (silence) to 1.0 (root mean square).
Audio.show
fn Audio.show(a: Audio): string No summary yet; the signature is the whole description.
tone
fn tone(pitch: Frequency, length: Duration): Audio A sine tone: \`tone(440Hz, 200ms)\`.
silence
fn silence(length: Duration): Audio No summary yet; the signature is the whole description.
Session.say
fn Session.say(s: Session, text: string) Send a user message as text.
Session.send
fn Session.send(s: Session, a: Audio) Stream a chunk of audio to the model.
Session.next
fn Session.next(s: Session): VoiceEvent Wait for the next event. After the session ends it is HungUp, again and again.
Session.interrupt
fn Session.interrupt(s: Session) Cancel the reply being spoken.
Session.stop
fn Session.stop(s: Session) No summary yet; the signature is the whole description.
Session.save
fn Session.save(s: Session): string The conversation so far, as JSON (the shape \`A.save()\` gives).