玻璃语音命令就近从给出的列表匹配 [英] Glass voice command nearest match from given list

查看:96
本文介绍了玻璃语音命令就近从给出的列表匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用玻璃,你可以通过'OK,玻璃'菜单中启动一个应用程序,它似乎挑最近的比赛,除非命令是英里,你可以很明显的看出命令的列表。
反正从应用程序内,或从语音提示(初始应用程序触发之后)都给予了类似的列表,并返回最匹配的。

With Glass you can launch an app via the 'OK, Glass' menu and it seems to pick the nearest match unless a command is miles off, and you can obviously see the list of commands.
Is there anyway from within the app, or from the voice prompt (after the initial app trigger) to have a similar list given and return the nearest match.

随机(非现实世界)例如,一个应用程序,显示了一个颜色,OK玻璃,显示红色

Random (non-real world) example, an app that shows you a colour, "OK Glass, show the colour red"

显示颜色可能是你的声音触发,似乎是匹配的玻璃上的近邻的方法,但是红是刚刚读入作为自由文本,并且可以很容易听错为害怕或者头',甚至是'读',因为没有办法的区分'从'红色'读。

'show the colour' could be your voice trigger and seems to be matched by glass on a 'nearest neighbor' method, however 'red' is just read in as free text and could be easily misheard as 'dread' or 'head', or even 'read' as there is no way of differentiating 'read' from 'red'.

有没有一种方法,以pre批准的选项(红,绿,蓝,橙*等)的列表传递到这个阶段,或其他语音提示在应用程序中,使用户可以看到列表,并获得更准确的结果时,有一组有限的预期反应(如主确定玻璃屏幕)?

Is there a way to pass a list of pre-approved option (red, green, blue, orange*, etc.) to this stage, or to another voice prompt within the app so the user can see the list and get more accurate results when there is a finite set of expected responses (like the main ok glass screen)?

*橙色确定好什么儿歌,我们很可能是安全有

*ok well nothing rhymes with orange, we're probably safe there

推荐答案

在谷歌GDK不支持此功能呢。然而,必要的功能已经在一些图书馆可用,您可以使用它们,只要GDK不支持此本身。 你所要做的:

The Google GDK doesn't support this feature yet. However, the necessary features are already available in some libraries and you can use them as long as the GDK doesn't support this natively. What you have to do:

  1. 从玻璃拉GlassVoice.apk:亚行拉/system/app/GlassVoice.apk

使用dex2jar这个apk文件转换成一个jar文件。

Use dex2jar to convert this apk into a jar file.

添加jar文件到您的构建路径

Add the jar file to your build path

现在你可以使用这个库是这样的:

Now you can use this library like this:

public class VoiceActivity extends Activity {

    private VoiceInputHelper mVoiceInputHelper;
    private VoiceConfig mVoiceConfig;

        @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.voice_activity);

        String[] items = {"red", "green", "blue", "orange"};
        mVoiceConfig = new VoiceConfig("MyVoiceConfig", items);
        mVoiceInputHelper = new VoiceInputHelper(this, new MyVoiceListener(mVoiceConfig),
                VoiceInputHelper.newUserActivityObserver(this));
    }

    @Override
    protected void onResume() {
        super.onResume();
        mVoiceInputHelper.addVoiceServiceListener();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mVoiceInputHelper.removeVoiceServiceListener();
    }

    public class MyVoiceListener implements VoiceListener {
        protected final VoiceConfig voiceConfig;

        public MyVoiceListener(VoiceConfig voiceConfig) {
            this.voiceConfig = voiceConfig;
        }

        @Override
        public void onVoiceServiceConnected() {
            mVoiceInputHelper.setVoiceConfig(mVoiceConfig, false);
        }

        @Override
        public void onVoiceServiceDisconnected() {

        }

        @Override
        public VoiceConfig onVoiceCommand(VoiceCommand vc) {
            String recognizedStr = vc.getLiteral();
            Log.i("VoiceActivity", "Recognized text: "+recognizedStr);

            return voiceConfig;
        }

        @Override
        public FormattingLogger getLogger() {
            return FormattingLoggers.getContextLogger();
        }

        @Override
        public boolean isRunning() {
            return true;
        }

        @Override
        public boolean onResampledAudioData(byte[] arg0, int arg1, int arg2) {
            return false;
        }

        @Override
        public boolean onVoiceAmplitudeChanged(double arg0) {
            return false;
        }

        @Override
        public void onVoiceConfigChanged(VoiceConfig arg0, boolean arg1) {

        }
    }

}

这篇关于玻璃语音命令就近从给出的列表匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆