Voice
Stream captured audio to an NPC and play back its spoken reply.
Voice runs over the same connection as text. The addon gives you the wire methods — streaming audio chunks in, receiving synthesized speech back — but capturing the player's microphone and deciding when they've stopped talking is up to you, using Godot's own audio APIs.
AudioEffectCapture on an AudioStreamMicrophone bus is the usual approach) and pass the addon raw PCM bytes.Sending audio
Stream chunks as you capture them, then send one final chunk with end = true — or let the server auto-finalize once it has buffered about 5MB, whichever comes first:
# pcm_chunk: PackedByteArray of raw audio you've already captured
connection.send_voice_chunk(pcm_chunk, false)
# ...more chunks as they're captured...
connection.send_voice_chunk(final_chunk, true) # end = truedataendsender_idOnce the server finishes transcribing, a transcript signal fires with what it heard, followed by the normal chat signals — voice replies arrive as one complete chat_chunk rather than streamed token by token, since grounding runs before anything is sent back.
Playing the reply
Synthesized speech arrives as raw binary WebSocket frames — no JSON envelope, one frame per sentence, in playback order:
connection.audio.connect(_on_audio)
func _on_audio(bytes: PackedByteArray) -> void:
# Raw synthesized speech for one sentence. Decode/queue it with
# AudioStreamGeneratorPlayback in your own playback pipeline.
play_audio_chunk(bytes)