start method

Future<void> start()

Open the microphone and begin the turn loop.

Throws SDKException when the session is closed or capture is refused.

Implementation

Future<void> start() async {
  if (_closed) {
    throw SDKException.invalidState('Voice session is closed');
  }
  if (_driver != null) return;
  final driver = VoiceAgentMicDriver();
  _driver = driver;
  _subscription = driver.events.listen(
    _forward,
    onError: (Object error) => _events.add(
      VoiceError('$error', recoverable: true),
    ),
  );
  await driver.start();
  _events.add(const VoiceAgentStateChanged(AgentState.listening));
}