Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

onError6 when i click "Mic button" help me issue.. #74

Open
loGTve opened this issue Dec 3, 2019 · 1 comment
Open

onError6 when i click "Mic button" help me issue.. #74

loGTve opened this issue Dec 3, 2019 · 1 comment

Comments

@loGTve
Copy link

loGTve commented Dec 3, 2019

Here My Codes
(Sorry i dont know how put those codes in box...)

``import 'package:flutter/material.dart';
import 'package:speech_recognition/speech_recognition.dart';

void main() => runApp(MainPage());

class MainPage extends StatelessWidget {
@OverRide
Widget build(BuildContext context) {

return MaterialApp(
  home: VoiceHome(),
);

}
}

class VoiceHome extends StatefulWidget {
@OverRide
_VoiceHomeState createState() => _VoiceHomeState();
}

class _VoiceHomeState extends State {
SpeechRecognition _speechRecognition;
bool _isAvailable = false;
bool _isListening = false;

String resultText = " ";

@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),
);

}

//UI
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Container(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
FloatingActionButton(
child: Icon(Icons.stop),
backgroundColor: Colors.pinkAccent,
onPressed: () {
_speechRecognition.stop().then(
(result) => setState(() => _isListening = result),
);
},
),
FloatingActionButton(
child: Icon(Icons.mic),
backgroundColor: Colors.deepPurple,
onPressed: () {
if (_isAvailable && !_isListening)
_speechRecognition
.listen(locale: "ko_KR")
.then((result) => print('$result'));
},
),
FloatingActionButton(
child: Icon(Icons.cancel),
mini: true,
backgroundColor: Colors.deepOrange,
onPressed: () {
if (_isListening)
_speechRecognition.cancel().then(
(result) => setState(() {
_isListening = result;
resultText = "";
}
),
);
},
),
],
),

        Container(
          width: MediaQuery.of(context).size.width * 0.6,
          decoration: BoxDecoration(
            color: Colors.indigo[100], 
            borderRadius: BorderRadius.circular(8.0),
          ),
          padding: EdgeInsets.symmetric(
            vertical: 10.0,
            horizontal: 12.0,
          ),
          child: Text(
            resultText
          ),
        )

      ],
    ),
  ),
);

}
}``

and Repo https://github.com/loGTve/soundtotexts

When i Debug it and press "mic" button
its shows
`
D/SpeechRecognitionPlugin( 7751): onRmsChanged : -2.12
D/SpeechRecognitionPlugin( 7751): onReadyForSpeech
D/SpeechRecognitionPlugin( 7751): onRmsChanged : -2.12
D/SpeechRecognitionPlugin( 7751): onRmsChanged : -2.12

......

I/chatty ( 7751): uid=10136(com.example.soundtotext) identical 33 lines
D/SpeechRecognitionPlugin( 7751): onRmsChanged : -2.0
D/SpeechRecognitionPlugin( 7751): onError : 6
`

How can i fix it?

@mointhedev
Copy link

Same error :/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants