sendAudio method
Sends one chunk of microphone audio. pcm16 must be 16-bit PCM, 16 kHz,
mono, little-endian. Chunk size: 80–200 ms is the sweet spot
(1280–3200 samples). Throws if called before connect.
Implementation
Future<void> sendAudio(Uint8List pcm16) async {
final ch = _channel;
if (ch == null) {
throw StateError('GeminiRealtimeClient.sendAudio: not connected');
}
_send({
'realtime_input': {
'media_chunks': [
{
'mime_type': 'audio/pcm;rate=16000',
'data': base64Encode(pcm16),
},
],
},
});
}