How to use Speech Recognition along with Porcupine

231 Views Asked by At

can anyone help me out on how to use speech recognition to listen right after porcupine wake up word. We need to some how figure out how to stop porcupine manager from listening the microphone until speech recognition is done listening to it.

try {
        Log.i("YOU SAID IT!", "yesss");
        porcupineManager = new PorcupineManager.Builder()
                .setKeyword(Porcupine.BuiltInKeyword.JARVIS)
                .setSensitivity(0.7f).build(
                        getApplicationContext(),
                        (keywordIndex) -> {
                            
                            // This is where I need to somehow stop so that I can trigger speech recognition to listen

                            numUtterances++;

                            PendingIntent contentIntent = PendingIntent.getActivity(
                                    this,
                                    0,
                                    new Intent(this, MainActivity.class),
                                    0);

                            final String contentText = numUtterances == 1 ? " time!" : " times!";
                            Notification n = new NotificationCompat.Builder(this, CHANNEL_ID)
                                    .setContentTitle("Wake word")
                                    .setContentText("Detected " + numUtterances + contentText)
                                    .setSmallIcon(R.drawable.ic_launcher_background)
                                    .setContentIntent(contentIntent)
                                    .build();

                            NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
                            assert notificationManager != null;
                            notificationManager.notify(1234, n);
                        });
        porcupineManager.start();
    } catch (PorcupineException e) {
        Log.e("PORCUPINE", e.toString());
    }
0

There are 0 best solutions below