小编Jas*_*ith的帖子

porcupineManager.stop() 和 .destroy() 不起作用

我一直在尝试实现一种应用程序检测唤醒词的方法,例如“Hey google”或“Jarvis”。我做了一些研究,发现 porcupine 有助于解决唤醒词问题,但现在的问题是我似乎无法触发 startRecognition() 再次侦听用户输入,然后继续进行。我仍然尝试触发 startRecognition() 但后来它要求我做 SpeechRecognizer.Destroy() 我尝试用 porcupine onDestroy 方法做但后来它停止工作。对不起,如果我混淆了任何人,我会附上我的代码我将非常感谢大家的帮助,因为我已经尝试解决这个问题一段时间了。

另一个问题是下面这行代码做了什么?

PendingIntent contentIntent = PendingIntent.getActivity(
                                    this,
                                    0,
                                    new Intent(this, MainActivity.class), // this line ?
                                    0);
Run Code Online (Sandbox Code Playgroud)

目前的代码:(

public class PorcupineService extends Service {

private static final int REQUEST_RECORD_AUDIO_PERMISSION_CODE = 1;
private SpeechRecognizer speechRecognizer;
TextToSpeech textToSpeech;
String userResponse;
Float speechRate = 2f;

private static final String CHANNEL_ID = "PorcupineServiceChannel";
private PorcupineManager porcupineManager;

private int numUtterances;

private void createNotificationChannel() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        NotificationChannel notificationChannel = new NotificationChannel( …
Run Code Online (Sandbox Code Playgroud)

java android android-studio

5
推荐指数
1
解决办法
107
查看次数

标签 统计

android ×1

android-studio ×1

java ×1