Examples · agents · 43 of 339
14-call
A phone call with an agent: microphone in, speaker out, until the call ends.
tin run examples/agents/14-call.tin --mic question.wav --speaker reply.wav// A phone call with an agent: microphone in, speaker out, until the call ends.
//
// In the playground, Run asks for the microphone; talk, and press Stop to hang up.
// On the CLI: tin run examples/agents/14-call.tin --mic question.wav --speaker reply.wav
// (or with sox installed, no flags: the default microphone and speaker).
//
// "mock" hears how long you spoke and answers with a tone. For a real voice, switch the
// model to "openai-realtime:gpt-realtime-mini" and give an OpenAI key.
/// What time it is at the front desk.
tool fn deskTime(): string => "it is 9:41 at the front desk"
voice agent FrontDesk {
model: "mock"
system: "You are the front desk of a small hotel. Be warm and brief."
tools: [deskTime]
on heard(text) => print("guest: {text}")
on said(text) => print("desk: {text}")
on bargeIn() => print(" (interrupted)")
}
fn main() {
let transcript = FrontDesk.talk(mic(), speaker())
print("--- call over ---")
print(transcript)
} guest: (0.6 s of speech)
desk: mock: (0.6 s of speech)
--- call over ---
user: (0.6 s of speech)
assistant: mock: (0.6 s of speech) This output is from a test microphone: 0.6 s of speech, then quiet. In the playground it listens to yours.