调用语音排队合成后,无法完整朗读,还没有朗读完整就到了下一个,下一个也是,该怎么办?
浪子晨荒诞不经 发布于2017-05 浏览:1777 回复:6
0
收藏


List bags = new ArrayList();


//我循环的增加了bags里面的对象

bags.add(getSpeechSynthesizeBag(speekInfo,i+""));

speak();


private void speak() {

//需要合成的文本text的长度不能超过1024个GBK字节。
       /*text = "欢迎使用百度语音合成SDK,百度语音为你提供支持。";*/

   int results = 0;

       results = this.mSpeechSynthesizer.batchSpeak(bags);

   if (results < 0) {
   }
}




收藏
点赞
0
个赞
共6条回复 最后由用户已被禁言回复于2022-04
#7fujiayi1984回复于2017-05

浪子晨荒诞不经:

您好,按照您提供的方式朗读可以了

1.但是有一个新的问题:我跳转了一个界面初始化socket,然后返回回来之后就不能朗读了。

2.speak2(); 和  NettHelper.SendMsg(str);两个方法都执行了,但只要存在NettHelper.SendMsg(str);就不会朗读?

void speak2(String str) {
if (active) {
speak(str);
try {
NettyHelper.sendMsg(str);
} catch (Exception e) {
e.printStackTrace();
}
}
} public static void sendMsg(String msg) throws Exception {
if(context == null) {
Log.d("context:", "context为空!内容:" + msg);
} else {
JSONObject json = new JSONObject();
json.put("StepMark", "rfid");
json.put("data", msg);
ByteBuf resp = Unpooled.copiedBuffer((json.toString() + PLANT_PORT_SPLIT).getBytes("UTF-8"));
context.writeAndFlush(resp);
Log.d("context:", "发送成功!内容:" + json.toString());
}
} public static ByteBuf copiedBuffer(byte[] array) {
return array.length == 0?EMPTY_BUFFER:wrappedBuffer((byte[])array.clone());

}

public static ByteBuf wrappedBuffer(byte[] array) {
return (ByteBuf)(array.length == 0?EMPTY_BUFFER:new UnpooledHeapByteBuf(ALLOC, array, array.length));
} protected UnpooledHeapByteBuf(ByteBufAllocator alloc, byte[] initialArray, int maxCapacity) {
this(alloc, initialArray, 0, initialArray.length, maxCapacity);
} private UnpooledHeapByteBuf(ByteBufAllocator alloc, byte[] initialArray, int readerIndex, int writerIndex, int maxCapacity) {
super(maxCapacity);
if(alloc == null) {
throw new NullPointerException("alloc");
} else if(initialArray == null) {
throw new NullPointerException("initialArray");
} else if(initialArray.length > maxCapacity) {
throw new IllegalArgumentException(String.format("initialCapacity(%d) > maxCapacity(%d)", new Object[]{Integer.valueOf(initialArray.length), Integer.valueOf(maxCapacity)}));
} else {
this.alloc = alloc;
this.setArray(initialArray);
this.setIndex(readerIndex, writerIndex);
}
} ChannelHandlerContext read();


回复浪子晨荒诞不经:

建议您慢慢删除代码,找到不能朗读的具体那一行代码。


0
#6浪子晨荒诞不经回复于2017-05

您好,按照您提供的方式朗读可以了

1.但是有一个新的问题:我跳转了一个界面初始化socket,然后返回回来之后就不能朗读了。

2.speak2(); 和  NettHelper.SendMsg(str);两个方法都执行了,但只要存在NettHelper.SendMsg(str);就不会朗读?

void speak2(String str) {
if (active) {
speak(str);
try {
NettyHelper.sendMsg(str);
} catch (Exception e) {
e.printStackTrace();
}
}
} public static void sendMsg(String msg) throws Exception {
if(context == null) {
Log.d("context:", "context为空!内容:" + msg);
} else {
JSONObject json = new JSONObject();
json.put("StepMark", "rfid");
json.put("data", msg);
ByteBuf resp = Unpooled.copiedBuffer((json.toString() + PLANT_PORT_SPLIT).getBytes("UTF-8"));
context.writeAndFlush(resp);
Log.d("context:", "发送成功!内容:" + json.toString());
}
} public static ByteBuf copiedBuffer(byte[] array) {
return array.length == 0?EMPTY_BUFFER:wrappedBuffer((byte[])array.clone());

}

public static ByteBuf wrappedBuffer(byte[] array) {
return (ByteBuf)(array.length == 0?EMPTY_BUFFER:new UnpooledHeapByteBuf(ALLOC, array, array.length));
} protected UnpooledHeapByteBuf(ByteBufAllocator alloc, byte[] initialArray, int maxCapacity) {
this(alloc, initialArray, 0, initialArray.length, maxCapacity);
} private UnpooledHeapByteBuf(ByteBufAllocator alloc, byte[] initialArray, int readerIndex, int writerIndex, int maxCapacity) {
super(maxCapacity);
if(alloc == null) {
throw new NullPointerException("alloc");
} else if(initialArray == null) {
throw new NullPointerException("initialArray");
} else if(initialArray.length > maxCapacity) {
throw new IllegalArgumentException(String.format("initialCapacity(%d) > maxCapacity(%d)", new Object[]{Integer.valueOf(initialArray.length), Integer.valueOf(maxCapacity)}));
} else {
this.alloc = alloc;
this.setArray(initialArray);
this.setIndex(readerIndex, writerIndex);
}
} ChannelHandlerContext read();


0
#5fujiayi1984回复于2017-05

浪子晨荒诞不经:

回复fujiayi1984:非常感谢您的回答,我会尽快测试,谢谢

回复浪子晨荒诞不经:

祝您测试顺利

0
#4浪子晨荒诞不经回复于2017-05

fujiayi1984:

回复浪子晨荒诞不经:

已经在QQ中回答过该问题

请自己添加类似代码:


private boolean active = true


void speak2(){

if (active){

speak();

}

}


void stop2(){

active = false;

stop();

}


回复fujiayi1984:非常感谢您的回答,我会尽快测试,谢谢

0
#3fujiayi1984回复于2017-05

浪子晨荒诞不经:


List bags = new ArrayList();


//我循环的增加了bags里面的对象

bags.add(getSpeechSynthesizeBag(speekInfo,i+""));

speak();


private void speak() {

//需要合成的文本text的长度不能超过1024个GBK字节。
       /*text = "欢迎使用百度语音合成SDK,百度语音为你提供支持。";*/

   int results = 0;

       results = this.mSpeechSynthesizer.batchSpeak(bags);

   if (results < 0) {
   }
}




回复浪子晨荒诞不经:

已经在QQ中回答过该问题

请自己添加类似代码:


private boolean active = true


void speak2(){

if (active){

speak();

}

}


void stop2(){

active = false;

stop();

}


0
#2周俊316回复于2017-05

浪子晨荒诞不经:


List bags = new ArrayList();


//我循环的增加了bags里面的对象

bags.add(getSpeechSynthesizeBag(speekInfo,i+""));

speak();


private void speak() {

//需要合成的文本text的长度不能超过1024个GBK字节。
       /*text = "欢迎使用百度语音合成SDK,百度语音为你提供支持。";*/

   int results = 0;

       results = this.mSpeechSynthesizer.batchSpeak(bags);

   if (results < 0) {
   }
}




回复浪子晨荒诞不经:

您好,收到您的疑问,稍后技术查看后,给您详细答复


0
TOP
切换版块