Flutter Speech_Recognition onError:6

时间:2019-12-03 06:01:20

标签: flutter dart speech-recognition

当我尝试在Flutter上使用Speech_Recognition时,以及当我单击“麦克风”按钮时...

它说 D / SpeechRecognitionPlugin(7751):onError:6

我发现这意味着ERROR_SPEECH_TIMEOUT 我尝试解决此问题。.我花了1周的时间无法修复它!

FloatingActionButton(
  child: Icon(Icons.mic),
  backgroundColor: Colors.deepPurple,
  onPressed: () {
    if (_isAvailable && !_isListening)
       _speechRecognition
       .listen(locale: "ko_KR")
       .then((result) => print('$result'));
     },
     ),

'''
@override
  void initState() {
    super.initState();
    initSpeechRecognizer();
  }

  void initSpeechRecognizer(){
    _speechRecognition = SpeechRecognition();

    _speechRecognition.setAvailabilityHandler(
      (bool result) => setState(() => _isAvailable = result)
    );

    _speechRecognition.setRecognitionStartedHandler(
      () => setState(() => _isListening = true),
    );

    _speechRecognition.setRecognitionResultHandler(
      (String speech) => setState(() => resultText = speech),
    );

    _speechRecognition.setRecognitionCompleteHandler(
      () => setState(() => _isListening = false),
    );

    _speechRecognition.activate().then(
      (result) => setState(() => _isAvailable = result),
    );
  }

该如何解决此错误?

0 个答案:

没有答案