initSpeechService method
Init a speech service that will use the provided recognizer to process
audio input from the device microphone.
This method may throw MicrophoneAccessDeniedException.
Implementation
Future<SpeechService> initSpeechService(final Recognizer recognizer) async {
if (await Permission.microphone.status == PermissionStatus.denied &&
await Permission.microphone.request() == PermissionStatus.denied) {
throw MicrophoneAccessDeniedException();
}
await _channel.invokeMethod('speechService.init', {
'recognizerId': recognizer.id,
'sampleRate': recognizer.sampleRate,
});
return SpeechService(_channel);
}