Fix speech crash

pull/123/head
FongMi 3 years ago
parent 9698fc7e8f
commit d06a08eb81
  1. 13
      app/src/leanback/java/com/fongmi/android/tv/ui/custom/CustomMic.java

@ -66,12 +66,19 @@ public class CustomMic extends AppCompatImageView {
else launcher.launch(Manifest.permission.RECORD_AUDIO);
}
private void startListening() {
try {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
recognizer.startListening(intent);
} catch (Exception ignored) {
}
}
public void start() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
setColorFilter(MDColor.RED_500, PorterDuff.Mode.SRC_IN);
recognizer.startListening(intent);
startAnimation(flicker);
startListening();
setListen(true);
}

Loading…
Cancel
Save