Commit 7f085a36 by 苗权威

09.30

parent ee773023
......@@ -515,11 +515,11 @@ public class ApachHttpUtils {
if (status == 200) {
HttpEntity httpEntity = response.getEntity();
if(httpEntity != null){
byte[] bytes = EntityUtils.toByteArray(httpEntity);
// String result = EntityUtils.toString(httpEntity, "UTF-8");
// byte[] bytes = EntityUtils.toByteArray(httpEntity);
String result = EntityUtils.toString(httpEntity, "UTF-8");
EntityUtils.consume(httpEntity);//关闭资源
// return result;
return String.valueOf(bytes.length);
return result;
// return String.valueOf(bytes.length);
}
}
}
......
......@@ -84,9 +84,14 @@ public class OkHttp3Utils {
paramsIterator.forEachRemaining(e -> urlBuild.addQueryParameter(e.getKey(), e.getValue()));
builder.url(urlBuild.build()).headers(headerBuilder.build());
Response response = client.newCall(builder.build()).execute();
try (ResponseBody body = response.body()){
// return String.valueOf(body.bytes().length);
return body.string();
} catch (Exception e) {
log.error("OKHTTP doGet error:"+e);
return null;
}
}
......
......@@ -154,7 +154,7 @@ public class DeployController {
log.error("文件为空");
return ServerResponse.createByErrorEnum(ResponseCode.DATA_IS_WRONG);
}
if(type.equals("default")) {
if("default".equals(type)) {
if (StringUtils.isAnyBlank(type, auth) || groupId == null) {
log.error("type:{}, auth:{}, groupId:{}", type, auth, groupId);
return ServerResponse.createByErrorEnum(ResponseCode.DATA_IS_WRONG);
......@@ -181,8 +181,8 @@ public class DeployController {
result = ApachHttpUtils.get(url, headers, null);
JSONObject resultJSONObject = JSON.parseObject(result);
if (ResponseCode.SUCCESS.getCode().equals(resultJSONObject.getIntValue("code"))) {
String path = "";
if(botAccount.equals("")) {
String path;
if("".equals(botAccount)) {
path = "/game_editor_tmp/background/";
}else {
path = "/game_editor_tmp"+File.separator+botAccount+"/background/";
......@@ -209,14 +209,11 @@ public class DeployController {
switch (sampleRate) {
case 8000 : sampleRate = 8000;break;
case 11025 : sampleRate = 11025;break;
case 16000 : sampleRate = 16000;break;
case 22050 : sampleRate = 22050;break;
case 32000 : sampleRate = 32000;break;
case 44100 : sampleRate = 44100;break;
case 47250 : sampleRate = 47250;break;
case 48000 : sampleRate = 48000;break;
case 50000 : sampleRate = 50000;break;
case 88200 : sampleRate = 88200;break;
case 96000 : sampleRate = 96000;break;
default: sampleRate = 44100;
}
if (!TTSUtils.changeAudioConfig(sampleRate, bitRate, Initialize.AUDIO_DIR+path)) {
......
......@@ -28,6 +28,8 @@ public class GeneralMP3Data {
private String npcName;
private String tmpName; // 用于试听生成的临时mp3文件名
// private String mode;
public GeneralMP3Data(String server, String text, String person, String tone, String botname,
Boolean cache, Double volume, Double speed, Double pitch) {
this.server = server;
......
......@@ -1547,6 +1547,7 @@ public class TTService {
switch (sampleRate) {
case 8000 : sampleRate = 8000;break;
case 11025 : sampleRate = 11025;break;
case 16000 : sampleRate = 16000;break;
case 22050 : sampleRate = 22050;break;
case 32000 : sampleRate = 32000;break;
case 44100 : sampleRate = 44100;break;
......@@ -1607,6 +1608,7 @@ public class TTService {
switch (sampleRate) {
case 8000 : sampleRate = 8000;break;
case 11025 : sampleRate = 11025;break;
case 16000 : sampleRate = 16000;break;
case 22050 : sampleRate = 22050;break;
case 32000 : sampleRate = 32000;break;
case 44100 : sampleRate = 44100;break;
......@@ -1935,15 +1937,12 @@ public class TTService {
}
switch (sampleRate) {
case 8000 : sampleRate = 8000;break;
case 16000 : sampleRate = 16000;break;
case 11025 : sampleRate = 11025;break;
case 22050 : sampleRate = 22050;break;
case 32000 : sampleRate = 32000;break;
case 44100 : sampleRate = 44100;break;
case 47250 : sampleRate = 47250;break;
case 48000 : sampleRate = 48000;break;
case 50000 : sampleRate = 50000;break;
case 88200 : sampleRate = 88200;break;
case 96000 : sampleRate = 96000;break;
default: sampleRate = 44100;
}
......@@ -2681,21 +2680,9 @@ public class TTService {
}
public static void main(String[] args) throws UnsupportedEncodingException {
Pattern pattern = Pattern.compile("1000[167]|1001[012]");
List<String> list = new ArrayList<>();
list.add("10001");
list.add("10006");
list.add("10007");
list.add("10010");
list.add("10011");
list.add("10012");
list.add("10013");
list.add("10002");
for (String item: list) {
Matcher matcher = pattern.matcher(item);
while (matcher.find()) {
System.out.println(matcher.group(0));
}
}
// String command = "soxi /home/yf01/下载/audioCut/1.mp3";
// String response = CallPython.soxiGetAudioConfig(command);
String response = "Input File : '/home/yf01/下载/audioCut/1.mp3'Channels : 1Sample Rate : 16000Precision : 16-bitDuration : 00:00:01.12 = 17856 samples ~ 83.7 CDDA sectorsFile Size : 4.46kBit Rate : 32.0kSample Encoding: MPEG audio (layer I, II or III)";
System.out.println(response);
}
}
......@@ -365,7 +365,9 @@ public class TTServiceEdition2 {
if (!TTSUtils.doesFileExist(path)) {
ResponseCodeWithData response1 = generalMP3(moodUrl, data, path, "GET",true);
if (response1 == null) response1 = new ResponseCodeWithData(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "tts_ls:generalMP3 return null");
// buildTTSTime(data.getText(), data.getPerson(), data.getText().length(), System.currentTimeMillis()-start);
// if (response1.getCode() == 200) {
// buildTTSTime(data.getText(), data.getPerson(), data.getText().length(), System.currentTimeMillis()-start);
// }
return response1;
}
} catch (Exception e) {
......@@ -483,6 +485,7 @@ public class TTServiceEdition2 {
private ResponseCodeWithData requestTemplate(String url, GeneralMP3Data data, String filePath, boolean getOnline) {
ResponseCodeWithData res;
// data.setMode("test");
int status = ApachHttpUtils.audioPost(url, JSON.toJSONString(data), filePath);
if (status == 0) res = new ResponseCodeWithData(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "请求出错");
else if (status == HttpServletResponse.SC_NOT_FOUND && Initialize.OFFLINE_SERVER.equals(url)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment