首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在android穿戴操作中更改语音识别器的语言

在android穿戴操作中更改语音识别器的语言
EN

Stack Overflow用户
提问于 2016-05-13 01:17:03
回答 1查看 502关注 0票数 2

在我的android应用程序中,我创建了一个带有佩戴功能的通知,并添加了一个动作来识别语音输入,并将语音文本发送到另一个活动。我的问题是它只能识别在google now设置(英语)中选择的语言,并且我想从波斯语中获得语音。这是我的代码:

代码语言:javascript
复制
RemoteInput remoteInput  = new RemoteInput.Builder("My_Const_String")
    .setLabel("label when you talk")
    .build();

Intent replayIntent = new Intent(context, MyTestActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, replayIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Action action = new NotificationCompat.Action.Builder(
        R.drawable.ic_btn, "Label when confirm your talk", pendingIntent)
        .addRemoteInput(remoteInput)
        .build();

NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
builder.setContentTitle("Title")
    .setContentText("Content text")
    .setSmallIcon(R.drawable.ic_stat_name)
    .setContentText("My text02");

NotificationCompat.WearableExtender extender =
        new NotificationCompat.WearableExtender();

extender.addAction(action);
builder.extend(extender);

NotificationManagerCompat mgr = NotificationManagerCompat.from(context);
int NotificatinId = 1;
mgr.notify(NotificatinId, builder.build());

另外,我不想强迫用户手动更改google now的设置。我试着添加额外的,如下所示,但它不起作用:

代码语言:javascript
复制
Intent i = new Intent();
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE_PREFERENCE, "fa_IR");
i.putExtra(RecognizerIntent.EXTRA_SUPPORTED_LANGUAGES, "fa_IR");
i.putExtra(RecognizerIntent.EXTRA_LANGUAGE, "fa");
Bundle bundle = new Bundle();
bundle = i.getExtras();

RemoteInput remoteInput  = new RemoteInput.Builder("My_Const_String")
    .setLabel("label when you talk")
    .addExtras(bundle)
    .build();
EN

回答 1

Stack Overflow用户

发布于 2016-05-23 19:40:32

它可以很好地处理法语和俄语。我认为Persian现在还不支持。看看“使用语音打字的语言”部分。

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37193515

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档