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
切换版块
浪子晨荒诞不经:
您好,按照您提供的方式朗读可以了
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();
回复浪子晨荒诞不经:
建议您慢慢删除代码,找到不能朗读的具体那一行代码。
您好,按照您提供的方式朗读可以了
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();
浪子晨荒诞不经:
回复fujiayi1984:非常感谢您的回答,我会尽快测试,谢谢
回复浪子晨荒诞不经:
祝您测试顺利
fujiayi1984:
回复浪子晨荒诞不经:
已经在QQ中回答过该问题
请自己添加类似代码:
private boolean active = true
void speak2(){
if (active){
speak();
}
}
void stop2(){
active = false;
stop();
}
回复fujiayi1984:非常感谢您的回答,我会尽快测试,谢谢
浪子晨荒诞不经:
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();
}
浪子晨荒诞不经:
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) {
}
}
回复浪子晨荒诞不经:
您好,收到您的疑问,稍后技术查看后,给您详细答复