Examples · learn/29-voice · 295 of 339
handlers
tin run examples/learn/29-voice/handlers.tinvoice agent Echo {
model: "mock"
// handlers run as the conversation goes, before next() hands the event on
on said(text) => print("[said] {text}")
}
fn main() {
let s = Echo.open()
s.say("hello there")
var audio = 0.0
loop {
match s.next() {
Speech(chunk) => {
audio = audio + chunk.seconds()
}
TurnDone => s.stop()
HungUp(reason) => break
_ => {}
}
}
print("{audio.fixed(2)} s of reply audio")
}