admin管理员组文章数量:1566364
2024年5月31日发(作者:)
InputStream inSt;
HttpsURLConnection webRequest;
try {
String accessToken = (_TTS_ACCESS_TOKEN);
if (y(accessToken)) {
webRequest = psConnection(_TOKEN_URI);
nput(true);
utput(true);
nectTimeout(5000);
dTimeout(5000);
uestMethod("POST");
byte[] bytes = new byte[0];
uestProperty("content-length", f());
uestProperty("Ocp-Apim-Subscription-Key", _KEY);
t();
DataOutputStream dop = new DataOutputStream(putStream());
(bytes);
();
();
inSt = utStream();
InputStreamReader in = new InputStreamReader(inSt);
BufferedReader bufferedReader = new BufferedReader(in);
StringBuilder strBuffer = new StringBuilder();
String line = null;
while ((line = ne()) != null) {
(line);
}
();
();
();
nect();
accessToken = ng();
//设置accessToken的过期时间为9分钟
(_TTS_ACCESS_TOKEN, accessToken, _TOKEN_EXPIRE_TIME);
("New tts access token {}", accessToken);
}
return accessToken;
} catch (Exception e) {
("Generate tts access token failed {}", sage());
}
return null;
}
}
4.字节数组处理
public class ByteArray {
private byte[] data;
private int length;
public ByteArray(){
length = 0;
data = new byte[length];
}
public ByteArray(byte[] ba){
data = ba;
length = ;
}
/**
合并数组
*/
public void cat(byte[] second, int offset, int length){
if( + length > ) {
int allocatedLength = (, length);
byte[] allocated = new byte[allocatedLength << 1];
opy(data, 0, allocated, 0, );
opy(second, offset, allocated, , length);
data = allocated;
}else {
opy(second, offset, data, , length);
}
+= length;
}
版权声明:本文标题:java实现微软文本转语音(TTS)经验总结 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1717138241a538574.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论