语音识别连接错误 [英] Voice Recognition Connection Error

查看:142
本文介绍了语音识别连接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I,M努力工作,通过和测试的基础上VoiceRecognition.java例如语音识别例如在<一个href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/VoiceRecognition.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/VoiceRecognition.html

但是,当单击按钮来创建活动中,我得到一个对话框,上面写着连接问题。我的清单文件是使用互联网的权限,以及我的理解传递给谷歌服务器。我需要做别的用呢。以下

code

更新2: 感谢史蒂夫,我已经能够直接在我的Droid安装USB驱动程序和调试应用程序。这里是LogCat中输出点击我的麦克风按钮:

  03-08 18:36:45.686:信息/ ActivityManager(1017):启动活动:意向{行动= android.speech.action.RECOGNIZE_SPEECH CMP = com.google.android。语音搜索/ .IntentApiActivity(有群众演员)}

03-08 18:36:45.686:WARN / ActivityManager(1017):活动推出的一项新的任务,所以取消活动的结果。

03-08 18:36:45.787:DEBUG / NetworkLocationProvider(1017):setMinTime:120000

03-08 18:36:45.889:信息/ ActivityManager(1017):显示活动com.google.android.voicesearch / .IntentApiActivity:135毫秒(总135毫秒)

03-08 18:36:45.905:DEBUG / NetworkLocationProvider(1017):onCellLocationChanged [802,0,0,4192,3]

03-08 18:36:45.951:信息/ MicrophoneInputStream(1429):启动语音识别与音频源VOICE_RECOGNITION

03-08 18:36:45.998:DEBUG / AudioHardwareMot(990):codeC的采样率已经16000

03-08 18:36:46.0​​92:信息/ RecognitionService(1429):ssfe URL = HTTP://www.google.com/m/voice-search

03-08 18:36:46.0​​92:WARN / RecognitionService(1429):所需的参数calling_package在IntentAPI请求失踪

03-08 18:36:46.115:DEBUG / AudioHardwareMot(990):codeC的采样率已经16000

03-08 18:36:46.131:WARN / InputManagerService(1017):对非重点客户com.android.internal.view.IInputMethodClient$Stub$Proxy@4487d240开始输入(UID = 10090 PID = 3132)

03-08 18:36:46.131:WARN / IInputConnectionWrapper(3132):showStatusIcon上的非活动InputConnection

03-08 18:36:46.248:WARN / MediaPlayer的(1429):信息/警告(1,44)
03-08 18:36:46.334:DEBUG / dalvikvm(3206):GC释放3682对象/ 369416字节293ms
03-08 18:36:46.358:WARN / MediaPlayer的(1429):信息/警告(1,44)
03-08 18:36:46.412:WARN / MediaPlayer的(1429):信息/警告(1,44)
03-08 18:36:46.444:WARN / MediaPlayer的(1429):信息/警告(1,44)
03-08 18:36:46.475:WARN / MediaPlayer的(1429):信息/警告(1,44)
03-08 18:36:46.506:WARN / MediaPlayer的(1429):信息/警告(1,44)
03-08 18:36:46.514:信息/ MediaPlayer的(1429):信息(1,44)
03-08 18:36:46.514:信息/ MediaPlayer的(1429):信息(1,44)
03-08 18:36:46.514:信息/ MediaPlayer的(1429):信息(1,44)
03-08 18:36:46.514:信息/ MediaPlayer的(1429):信息(1,44)
03-08 18:36:46.514:信息/ MediaPlayer的(1429):信息(1,44)
03-08 18:36:46.514:信息/ MediaPlayer的(1429):信息(1,44)
 

这是我关心的是缺少的参数调用包的警告。该行

更新: 好吧,我能有一个从出现来与谷歌语音搜索HTC取代我的仿真影像,但现在当我在模拟器中运行,我得到的声音问题消息,重新留言或取消按钮。看来,使其恢复到onActivityResult(),但结果code为0。

下面是LogCat中输出:

  03-07 20:21:25.396:信息/ ActivityManager(578):启动活动:意向{行动= android.speech.action.RECOGNIZE_SPEECH补偿= {com.google.android .voicesearch / com.google.android.voicesearch.RecognitionActivity}(有群众演员)}

03-07 20:21:2540.6:WARN / ActivityManager(578):活动推出的一项新的任务,所以取消活动的结果。

03-07 20:21:25.968:WARN / ActivityManager(578):活动暂停超时HistoryRecord {434f7850 {com.ikonicsoft.mileagegenie / com.ikonicsoft.mileagegenie.MileageGenie}}

03-07 20:21:26.206:WARN / AudioHardwareInterface(554):getInputBufferSize坏采样率:16000

03-07 20:21:26.256:ERROR / AudioRecord(819):不支持录音参数:采样率16000,信道计数1,格式1

03-07 20:21:26.696:信息/ ActivityManager(578):显示活动com.google.android.voicesearch / .RecognitionActivity:1295毫秒

03-07 20:21:29.890:DEBUG / dalvikvm(806):主题ID = 3:仍暂停撤消后(S = 1 D = 1)

03-07 20:21:29.896:信息/ dalvikvm(806):未捕获的异常被抛出的终结(将被丢弃):

03-07 20:21:29.896:信息/ dalvikvm(806):Ljava /朗/ IllegalStateException异常;:最终化光标android.database.sqlite.SQLiteCursor@435d3c50上ml_trackdata尚未停用或关闭

03-07 20:21:29.896:信息/ dalvikvm(806):在android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)

03-07 20:21:29.896:信息/ dalvikvm(806):在dalvik.system.NativeStart.run(本机方法)

03-07 20:21:31.468:DEBUG / dalvikvm(806):主题ID = 5:仍然暂停撤消后(S = 1 D = 1)

03-07 20:21:32.436:WARN / IInputConnectionWrapper(806):showStatusIcon上的非活动InputConnection
 

我,还在原地不知道为什么I,M获取连接的问题在Droid上。我可以使用语音搜索确定。我也试过清除缓存和数据在某些职位描述,butstill不工作?

  / **
*火的意图来启动语音识别活动。
* /
私人无效startVoiceRecognitionActivity(){
意向意图=新的意图(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT,语音识别演示);
startActivityForResult(意向,VOICE_RECOGNITION_REQUEST_ code);
}

/ **
*处理来自表彰活动的结果。
* /
@覆盖
保护无效onActivityResult(INT申请code,INT结果code,意图数据){
  如果(要求code == VOICE_RECOGNITION_REQUEST_ code和;&安培;结果code == RESULT_OK){
  //填充列表视图中的字符串识别器认为它可能已经听说
  ArrayList的&LT;字符串&GT;比赛= data.getStringArrayListExtra(
  RecognizerIntent.EXTRA_RESULTS);
  mList.setAdapter(新ArrayAdapter&LT;字符串&GT;(这一点,android.R.layout.simple_list_item_1,
比赛));
}

super.onActivityResult(要求code,因此code,数据);
}
 

解决方案

好吧......问题解决。

使用RecognizerIntent时launchMode =singleInstance:

看样子你不能使用机器人。我删除了这起明显和语音搜索运行正常。

再次感谢史蒂夫,对USB调试设备上的信息。非常方便。

I,m trying to work through and test a Voice Recognition example based on the VoiceRecognition.java example at http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/VoiceRecognition.html

but when click on the button to create the activity, I get a dialog that says Connection problem. My Manifest file is using the Internet Permission, and I understand it passes the to the Google Servers. Do I need to do anything else to use this. Code below

UPDATE 2: Thanks to Steve, I have been able to install the USB Driver and debug the app directly on my Droid. Here is the LogCat output from clicking on my mic button:

03-08 18:36:45.686: INFO/ActivityManager(1017): Starting activity: Intent { act=android.speech.action.RECOGNIZE_SPEECH cmp=com.google.android.voicesearch/.IntentApiActivity (has extras) }

03-08 18:36:45.686: WARN/ActivityManager(1017): Activity is launching as a new task, so cancelling activity result.

03-08 18:36:45.787: DEBUG/NetworkLocationProvider(1017): setMinTime: 120000

03-08 18:36:45.889: INFO/ActivityManager(1017): Displayed activity com.google.android.voicesearch/.IntentApiActivity: 135 ms (total 135 ms)

03-08 18:36:45.905: DEBUG/NetworkLocationProvider(1017): onCellLocationChanged [802,0,0,4192,3]

03-08 18:36:45.951: INFO/MicrophoneInputStream(1429): Starting voice recognition with audio source VOICE_RECOGNITION

03-08 18:36:45.998: DEBUG/AudioHardwareMot(990): Codec sampling rate already 16000

03-08 18:36:46.092: INFO/RecognitionService(1429): ssfe url=http://www.google.com/m/voice-search

03-08 18:36:46.092: WARN/RecognitionService(1429): required parameter 'calling_package' is missing in IntentAPI request

03-08 18:36:46.115: DEBUG/AudioHardwareMot(990): Codec sampling rate already 16000

03-08 18:36:46.131: WARN/InputManagerService(1017): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@4487d240 (uid=10090 pid=3132)

03-08 18:36:46.131: WARN/IInputConnectionWrapper(3132): showStatusIcon on inactive InputConnection

03-08 18:36:46.248: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.334: DEBUG/dalvikvm(3206): GC freed 3682 objects / 369416 bytes in 293ms
03-08 18:36:46.358: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.412: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.444: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.475: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.506: WARN/MediaPlayer(1429): info/warning (1, 44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)
03-08 18:36:46.514: INFO/MediaPlayer(1429): Info (1,44)

The line that concerns me is the warning of the missing parameter calling-package.

UPDATE: Ok, I was able to replace my emulator image with one from HTC that appears to come with Google Voice Search, however now when I run from the emulator, i'm getting an Audio Problem message with Speak Again or Cancel buttons. It appears to make it back to the onActivityResult(), but the resultCode is 0.

Here is the LogCat output:

03-07 20:21:25.396: INFO/ActivityManager(578): Starting activity: Intent { action=android.speech.action.RECOGNIZE_SPEECH comp={com.google.android.voicesearch/com.google.android.voicesearch.RecognitionActivity} (has extras) }

03-07 20:21:25.406: WARN/ActivityManager(578): Activity is launching as a new task, so cancelling activity result.

03-07 20:21:25.968: WARN/ActivityManager(578): Activity pause timeout for HistoryRecord{434f7850 {com.ikonicsoft.mileagegenie/com.ikonicsoft.mileagegenie.MileageGenie}}

03-07 20:21:26.206: WARN/AudioHardwareInterface(554): getInputBufferSize bad sampling rate: 16000

03-07 20:21:26.256: ERROR/AudioRecord(819): Recording parameters are not supported: sampleRate 16000, channelCount 1, format 1

03-07 20:21:26.696: INFO/ActivityManager(578): Displayed activity com.google.android.voicesearch/.RecognitionActivity: 1295 ms

03-07 20:21:29.890: DEBUG/dalvikvm(806): threadid=3: still suspended after undo (s=1 d=1)

03-07 20:21:29.896: INFO/dalvikvm(806): Uncaught exception thrown by finalizer (will be discarded):

03-07 20:21:29.896: INFO/dalvikvm(806): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@435d3c50 on ml_trackdata that has not been deactivated or closed

03-07 20:21:29.896: INFO/dalvikvm(806):     at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:596)

03-07 20:21:29.896: INFO/dalvikvm(806):     at dalvik.system.NativeStart.run(Native Method)

03-07 20:21:31.468: DEBUG/dalvikvm(806): threadid=5: still suspended after undo (s=1 d=1)

03-07 20:21:32.436: WARN/IInputConnectionWrapper(806): showStatusIcon on inactive InputConnection

I,m still not sure why I,m getting the Connect problem on the Droid. I can use Voice Search ok. I also tried clearing the cache, and data as described in some posts, butstill not working??

/**
* Fire an intent to start the speech recognition activity.
*/
private void startVoiceRecognitionActivity() {
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Speech recognition demo");
startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
}

/**
* Handle the results from the recognition activity.
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
  // Fill the list view with the strings the recognizer thought it could have heard
  ArrayList<String> matches = data.getStringArrayListExtra(
  RecognizerIntent.EXTRA_RESULTS);
  mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
matches));
}

super.onActivityResult(requestCode, resultCode, data);
}

解决方案

Ok... problem fixed.

It appears you cannot use android:launchMode="singleInstance" when using the RecognizerIntent. I removed this from the manifest and the Voice Search runs correctly.

Thanks again Steve, for the info on USB debugging on the device. Very handy.

这篇关于语音识别连接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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