Android SDK采用流的方式无法识别写过来的pcm数据
Leautolink 发布于2017-10 浏览:2555 回复:3
0
收藏

我使用的服务是:语音识别服务

调用的接口是:

  1. asr.send(SpeechConstant.ASR_START, json, null, 0, 0);

参数设置情况:

params.put(SpeechConstant.NLU, "enable");
params.put(SpeechConstant.ACCEPT_AUDIO_VOLUME, false);
params.put(SpeechConstant.VAD, SpeechConstant.VAD_DNN);
params.put(SpeechConstant.SOUND_START, R.raw.start_tone);
params.put(SpeechConstant.PID, 15361);
params.put(SpeechConstant.ACCEPT_AUDIO_DATA, true);
params.put(SpeechConstant.IN_FILE,
       "#com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream"
               + ".create16kStream()");

开发平台和机型:android

SDK版本号:3.0.3

代码或日志截图(上传截图能帮助您更快解决问题):

复现步骤、现象及其他描述:

通过另一设备将pcm数据,通过流的方式写入VoiceInputStream(是继承InputStream)的,在SpeechConstant.ASR_START的参数里添加inputFile的类型为

"#com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream"
               + ".create16kStream()"

,从log看也一直在读:

10-27 17:46:16.575 I/XXX     (21684): --->read: com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream@356851a  buffer.length: 1920000  thread  id =2864

但没有识别出传过来的pcm.

最后返回:

10-27 17:46:30.374 I/XXX     (21684): --->read: com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream@356851a  buffer.length: 1920000  thread  id =2864

10-27 17:46:30.387 I/BaiduSTTEngine(21684): onEvent---- params : {"origin_result":{"sn":"","error":2,"desc":"Network is not available","sub_error":2100},"error":2,"desc":"Network is not available","sub_error":2100}

10-27 17:46:30.394 I/XXX     (21684): --->read: com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream@356851a  size: 0


请问两个问题:

1、InputStream读取有什么要求,之前我们发现读取的byteCount 为3200,现在改为3.0.3版本发现这个值为640了,不知道目前变化了,我们给buffer的时候有什么限制?

2、为何我直接将inputstrem用文件打开赋值为InputStream的方式可以识别,且没看到去调用read的方法,而我采用流的方式向inputstrem里面write数据,就看到有过来调取read,但没有识别?


收藏
点赞
0
个赞
共3条回复 最后由用户已被禁言回复于2022-04
#4200754yu回复于2017-12

解决这个问题了吗?

 

0
#3Leautolink回复于2017-11

fujiayi1984:

回复Leautolink:1. 请将demo中的16k_test.pcm 与你的pcm做对比,注意pcm编码是小端的。640的值不影响你的逻辑。此外不要一下子塞过多的数据,数据过多时可以暂停。

2.请测试demo中的infile参数。 InputStream是否存在write方法,请看android官方文档

回复fujiayi1984: InputStream write方法是我们自己添加的,使用2.1.20的sdk是没问题的,使用2.1.20的sdk我们是看到是过来读的,读完会将语音识别成文字的,但3.0.3的sdk版本有读取的动作,但无法识别了。


查看了demo,demo里只是将InputStream这个对象作为参数塞给sdk,其他的怎么处理并没有看到。2.1.20版本我们将InputStream这个对象作为参数塞给sdk,然后我们往inputstream里写数据,sdk读数据,读完会识别出来,识别完成后我们会停止写入数据;现在3.0.3sdk我们同样也是把InputStream对象给sdk,同样的逻辑,但发现sdk一直在读取,根本无法识别。请问3.0.3sdk和2.1.20sdk在使用流的方式有什么区别,我们需要做哪些相应的调整?


0
#2fujiayi1984回复于2017-10

Leautolink:

我使用的服务是:语音识别服务

调用的接口是:

  1. asr.send(SpeechConstant.ASR_START, json, null, 0, 0);

参数设置情况:

params.put(SpeechConstant.NLU, "enable");
params.put(SpeechConstant.ACCEPT_AUDIO_VOLUME, false);
params.put(SpeechConstant.VAD, SpeechConstant.VAD_DNN);
params.put(SpeechConstant.SOUND_START, R.raw.start_tone);
params.put(SpeechConstant.PID, 15361);
params.put(SpeechConstant.ACCEPT_AUDIO_DATA, true);
params.put(SpeechConstant.IN_FILE,
       "#com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream"
               + ".create16kStream()");

开发平台和机型:android

SDK版本号:3.0.3

代码或日志截图(上传截图能帮助您更快解决问题):

复现步骤、现象及其他描述:

通过另一设备将pcm数据,通过流的方式写入VoiceInputStream(是继承InputStream)的,在SpeechConstant.ASR_START的参数里添加inputFile的类型为

"#com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream"
               + ".create16kStream()"

,从log看也一直在读:

10-27 17:46:16.575 I/XXX     (21684): --->read: com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream@356851a  buffer.length: 1920000  thread  id =2864

但没有识别出传过来的pcm.

最后返回:

10-27 17:46:30.374 I/XXX     (21684): --->read: com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream@356851a  buffer.length: 1920000  thread  id =2864

10-27 17:46:30.387 I/BaiduSTTEngine(21684): onEvent---- params : {"origin_result":{"sn":"","error":2,"desc":"Network is not available","sub_error":2100},"error":2,"desc":"Network is not available","sub_error":2100}

10-27 17:46:30.394 I/XXX     (21684): --->read: com.leautolink.multivoiceengins.engine.stt.stream.VoiceInputStream@356851a  size: 0


请问两个问题:

1、InputStream读取有什么要求,之前我们发现读取的byteCount 为3200,现在改为3.0.3版本发现这个值为640了,不知道目前变化了,我们给buffer的时候有什么限制?

2、为何我直接将inputstrem用文件打开赋值为InputStream的方式可以识别,且没看到去调用read的方法,而我采用流的方式向inputstrem里面write数据,就看到有过来调取read,但没有识别?


回复Leautolink:1. 请将demo中的16k_test.pcm 与你的pcm做对比,注意pcm编码是小端的。640的值不影响你的逻辑。此外不要一下子塞过多的数据,数据过多时可以暂停。

2.请测试demo中的infile参数。 InputStream是否存在write方法,请看android官方文档

0
TOP
切换版块