配置话语和暂停的长度在Android的语音识别 [英] Configuring the length of utterance and pauses in Android's speech recognizer

查看:362
本文介绍了配置话语和暂停的长度在Android的语音识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经Android的语音到文本API讲的东西到手机上,并转换成文本。默认情况下,如果一个停止说话的麦克风,该API假设用户完成通话,并返回从输入语音的文本。

有关我的应用程序,用户可能有她连续的句子之间长的停顿。如何配置Android的语音到文本的API来考虑的讲话结束只有当我要求它和扬声器采用句子之间一个小小的停顿不就是尽快做什么?谢谢!

下面是我当前的实现,它简单地转换成语音的用户采取句子之间一个小小的停顿尽快文本:

  @覆盖
保护无效的onActivityResult(INT申请code,INT结果code,意图数据){
    super.onActivityResult(要求code,结果code,数据);    开关(要求code){
    案例RESULT_SPEECH:{
        如果(结果code == RESULT_OK&放大器;&安培; NULL =数据!){            ArrayList的<串GT;文本=数据
                    .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);            txtText.setText(text.get(0));
        }
        打破;
    }    }
}


解决方案

到Android 4.1(或谷歌搜索/现在应用的用户),这会为你工作前值:

  INT someValue中= 5;
intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS,Long.valueOf(someValue中* 1000L));

不幸的是以后的版本不再对此有何反应参数,一个莫大的耻辱,因为它使冗长的笔记或电子邮件撰写不可能....

我带来了问题他们的注意。

I have android's Speech To Text API to speak something to the phone and convert it into text. By default, if one stops speaking to the microphone, the API assumes that the user is done talking and returns the text from the input speech.

For my application, the user might have long pauses between her consecutive sentences. How can I configure Android's speech to text API to consider the end of the speech only when I ask it to and not do that as soon as the speaker takes a small pause between sentences? Thanks!

Here is my current implementation which simply converts speech to text as soon as the user takes a small pause between sentences:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    switch (requestCode) {
    case RESULT_SPEECH: {
        if (resultCode == RESULT_OK && null != data) {

            ArrayList<String> text = data
                    .getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);

            txtText.setText(text.get(0));
        }
        break;
    }

    }
}

解决方案

Prior to Android 4.1 (or users of the Google Search/Now app) this will work for you:

int someValue = 5;
intent.putExtra(RecognizerIntent.EXTRA_SPEECH_INPUT_COMPLETE_SILENCE_LENGTH_MILLIS, Long.valueOf(someValue * 1000L));

Unfortunately later versions no longer react to this parameter, a great shame as it makes lengthy note taking or email composing impossible....

I have brought the issue to their attention.

这篇关于配置话语和暂停的长度在Android的语音识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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