语音识别-带模板(android穿)

Voice recognition - with templates (android wear)

我正在尝试为 Android wear 开发一个应用程序,单击按钮会要求用户说出一些内容并将其发送到网络服务器。我还需要一个预定义模板列表,类似于 Hangouts 的工作方式。

我尝试过的:

    Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
    intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
    intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Send to server");
    startActivityForResult(intent, SPEECH_REQUEST_CODE);

这可行,但我无法为用户提供一组预定义模板。

阅读此 - https://developer.android.com/training/wearables/notifications/voice-input.html 我看到可以在通知中执行此操作......但这不会在前面,我需要这个 UI 是 modal/blocking,所以通知不适合我的用例。

我有哪些选择?我该如何实施?

遗憾的是,除了 Receiving Voice Input in a Notification 之外,没有其他方法可以使用带有预定义文本响应的语音识别。

基于文档:Adding Voice Capabilities

Voice actions are an important part of the wearable experience. They let users carry out actions hands-free and quickly. Wear provides two types of voice actions:

System-provided

  • These voice actions are task-based and are built into the Wear platform. You filter for them in the activity that you want to start when the voice action is spoken. Examples include "Take a note" or "Set an alarm".

App-provided

  • These voice actions are app-based, and you declare them just like a launcher icon. Users say "Start " to use these voice actions and an activity that you specify starts.

同样如 24543484 and 22630600 中所述,两者都在 android 中实施了通知以获取语音输入。

希望对您有所帮助。