Commit 7542ddaf by 苗权威

8.11

parent c44f1797
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AliControlFlowStatementWithoutBraces" enabled="false" level="BLOCKER" enabled_by_default="false" />
<inspection_tool class="Duplicates" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
<inspection_tool class="JavaDoc" enabled="true" level="WARNING" enabled_by_default="true">
<option name="TOP_LEVEL_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="INNER_CLASS_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="METHOD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="@return@param@throws or @exception" />
</value>
</option>
<option name="FIELD_OPTIONS">
<value>
<option name="ACCESS_JAVADOC_REQUIRED_FOR" value="none" />
<option name="REQUIRED_TAGS" value="" />
</value>
</option>
<option name="IGNORE_DEPRECATED" value="false" />
<option name="IGNORE_JAVADOC_PERIOD" value="true" />
<option name="IGNORE_DUPLICATED_THROWS" value="false" />
<option name="IGNORE_POINT_TO_ITSELF" value="false" />
<option name="myAdditionalJavadocTags" value="date" />
</inspection_tool>
</profile>
</component>
\ No newline at end of file
<component name="InspectionProjectProfileManager">
<settings>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="INFORMATION" />
<item index="1" class="java.lang.String" itemvalue="TYPO" />
<item index="2" class="java.lang.String" itemvalue="SERVER PROBLEM" />
<item index="3" class="java.lang.String" itemvalue="WEAK WARNING" />
<item index="4" class="java.lang.String" itemvalue="INFO" />
<item index="5" class="java.lang.String" itemvalue="WARNING" />
<item index="6" class="java.lang.String" itemvalue="ERROR" />
</list>
</settings>
</component>
\ No newline at end of file
......@@ -80,38 +80,39 @@ public class ApachHttpUtils {
connManager.setMaxTotal(1000);//最大连接数设置
connManager.setDefaultMaxPerRoute(800);//per route最大连接数设置
// ConnectionKeepAliveStrategy myStrategy = (response, context) -> {
// HeaderElementIterator it = new BasicHeaderElementIterator(
// response.headerIterator(HTTP.CONN_KEEP_ALIVE));
// while (it.hasNext()) {
// HeaderElement he = it.nextElement();
ConnectionKeepAliveStrategy myStrategy = (response, context) -> {
HeaderElementIterator it = new BasicHeaderElementIterator(
response.headerIterator(HTTP.CONN_KEEP_ALIVE));
while (it.hasNext()) {
HeaderElement he = it.nextElement();
String param = he.getName();
String value = he.getValue();
// log.info("CONN_KEEP_ALIVE:{}:{}",param,value);
if ("timeout".equalsIgnoreCase(param)) {
try {
return Long.parseLong(value) * 1000;
} catch(NumberFormatException ignore) {
}
break;
}
}
// HeaderElementIterator connectionClose = new BasicHeaderElementIterator(
// response.headerIterator(HTTP.CONN_DIRECTIVE));
// while (connectionClose.hasNext()) {
// HeaderElement he = connectionClose.nextElement();
// String param = he.getName();
// String value = he.getValue();
// log.info("CONN_KEEP_ALIVE:{}:{}",param,value);
// if (value != null && param.equalsIgnoreCase("timeout")) {
// try {
// return Long.parseLong(value) * 1000;
// } catch(NumberFormatException ignore) {
// }
// }
// log.info("CONN_DIRECTIVE:{}:{}",param,value);
// }
//
//// HeaderElementIterator connectionClose = new BasicHeaderElementIterator(
//// response.headerIterator(HTTP.CONN_DIRECTIVE));
//// while (connectionClose.hasNext()) {
//// HeaderElement he = connectionClose.nextElement();
//// String param = he.getName();
//// String value = he.getValue();
//// log.info("CONN_DIRECTIVE:{}:{}",param,value);
//// }
// return 1;
// };
return 0;
};
httpClient = HttpClients.custom()
.setConnectionManager(connManager)
.setRetryHandler(new CustomRetry())
.setDefaultRequestConfig(requestConfig)
.setKeepAliveStrategy(new DefaultConnectionKeepAliveStrategy())
.setKeepAliveStrategy(myStrategy)
.evictIdleConnections(5, TimeUnit.SECONDS)
.build();
......@@ -526,6 +527,46 @@ public class ApachHttpUtils {
return null;
}
public static String delete(String url, Map<String, String> headers, Map<String, String> params) {
try {
URIBuilder builder = new URIBuilder(url, StandardCharsets.UTF_8);
if (!CollectionUtils.isEmpty(params)) {
List<NameValuePair> list = new ArrayList<>();
BasicNameValuePair param;
for (Map.Entry<String, String> entry: params.entrySet()) {
param = new BasicNameValuePair(entry.getKey(), entry.getValue());
list.add(param);
}
builder.setParameters(list);
}
HttpDelete httpDelete = new HttpDelete(builder.build());
if (!CollectionUtils.isEmpty(headers)) {
for (Map.Entry<String, String> entry:headers.entrySet()) {
httpDelete.setHeader(entry.getKey(), entry.getValue());
}
}
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(3000)
.setSocketTimeout(20000)
.setConnectTimeout(10000).build();
httpDelete.setConfig(requestConfig);
try (CloseableHttpResponse response = getHttpClient().execute(httpDelete)){
int status = response.getStatusLine().getStatusCode();//获取返回状态值
if (status == 200) {
HttpEntity httpEntity = response.getEntity();
if(httpEntity != null){
String result = EntityUtils.toString(httpEntity, "UTF-8");
EntityUtils.consume(httpEntity);//关闭资源
return result;
}
}
}
} catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e));
}
return null;
}
public static String requestByPostParts(Map<String,Object> map, String url, Charset charset, Map<String, String> headers) {
try {
HttpPost post = new HttpPost(url);
......
......@@ -693,19 +693,17 @@ public class TTSUtils {
}
public static void main(String[] args) throws IOException, UnsupportedAudioFileException {
// UploadCallbackUnzip("/home/yf01/下载/tts/testzip","/home/yf01/下载/testUnzip.zip");
// Files.copy(Paths.get("/home/yf01/下载/d46f2708a6a79f5bcc4623b1030b8aca.mp3"), Paths.get("/home/yf01/下载/d46Test.mp3"));
// System.out.println(buildMP3Filename("你是八星团的杜磊吧!我等你很久了,我叫周笑笑"));
// System.out.println(buildMP3Filename("先进来坐坐吧"));
// System.out.println(buildMP3Filename(" 先进来坐坐吧"));
// System.out.println(buildMP3Filename("周笑笑把门打开,露出了女性特有的粉色公主房,坐在软绵绵的坐垫上,12岁的小女孩有点手足无措"));
// System.out.println(buildMP3Filename("你要喝些什么吗?我这里有果汁和可乐"));
List<String> list = new ArrayList<>();
list.add("12345");
list.add("abcdg");
list.add("w35252");
System.out.println(Arrays.toString(list.toArray()));
// System.out.println(pythonlistToStr(list));
// List<String> filePathList = new ArrayList<>();
// filePathList.add("/home/yf01/下载/audioConcate/1.wav");
// filePathList.add("/home/yf01/下载/audioConcate/2.wav");
// List<String> str = filePathList.stream().map(s -> "-i "+s).collect(Collectors.toList());
// StringBuilder builder = new StringBuilder("ffmpeg ").append(StringUtils.join(str, " ")).append(" -filter_complex ");
// for (int i = 0; i < filePathList.size(); i++) {
// builder.append("[").append(i).append(":a:0]");
// }
// builder.append("concat=n=").append(filePathList.size()).append(":v=0:a=1[a] -map [a] ").append("/home/yf01/下载/audioConcate/result.wav");
// System.out.println(builder.toString());
// System.out.println(buildMP3Filename("苹果"));
// System.out.println(buildMP3Filename("没有了哦,换其他的水果"));
}
}
package ai.qiwu.com.tts_service.pojo.deploy;
import lombok.Getter;
import lombok.Setter;
/**
* painter
* 20-8-3 上午10:35
*/
@Getter
@Setter
public class MoveBotAudio {
private String srcBotAccount;
private String destBotAccount;
}
package ai.qiwu.com.tts_service.pojo.deploy;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
@Getter
@Setter
public class Result implements Serializable {
private static final long serialVersionUID = -3948389268046368059L;
private Integer code;
private String msg;
private Object data;
public static Result success() {
Result result = new Result();
result.setCode(1);
return result;
}
public static Result failure(String msg) {
Result result = new Result();
result.setCode(500);
result.setMsg(msg);
return result;
}
}
\ No newline at end of file
......@@ -96,13 +96,13 @@ public class Initialize implements InitializingBean {
/**
* 程序部署地址
*/
private static final String SERVER_URL;
public static final String SERVER_URL;
private static final String SERVER_URL_CDN;
/**
* 音频文件目录
*/
private static final String AUDIO_DIR;
public static final String AUDIO_DIR;
/**
* 压缩包上传目录
*/
......
......@@ -122,7 +122,7 @@ public class TTService {
final AtomicInteger hasRecord = new AtomicInteger();
// 过滤掉record目录
File[] needDelete = deleteBotDir.listFiles((dir, name) -> {
if (name.equals(Initialize.getUploadedDir())) {
if (StringUtils.equalsAny(name, Initialize.getUploadedDir(), "Liehu1") || name.startsWith("Baidu")) {
hasRecord.set(1);
return false;
}
......
......@@ -555,30 +555,31 @@ public class TTServiceEdition2 {
.append((filename=TTSUtils.buildMP3Filename(notVariableText))).toString();
//log.info("notVariableTextPath:{}",notVariableTextPath);
if (!TTSUtils.doesFileExist(notVariableTextPath)) {
if (Initialize.getThirdPartyTts().contains(data.getPerson()) && !"Liehu1".equals(data.getPerson())) {
String thirdPath = new StringBuilder(usDir).append(File.separator).append(filename).toString();
if (!TTSUtils.doesFileExist(thirdPath)) {
if (notVariableTextArray.length == 1) {
if ("Liehu1".equals(data.getPerson())) return false;
String thirdPath = new StringBuilder(usDir).append(File.separator).append(filename).toString();
if (!TTSUtils.doesFileExist(thirdPath)) {
if (notVariableTextArray.length == 1) {
GeneralMP3Data variableData = new GeneralMP3Data(data.getServer(), notVariableText,data.getPerson(),
data.getTone(), data.getBotname(), data.getCache(),data.getVolume(),data.getSpeed(),data.getPitch());
ResponseCodeWithData response = generalMP3(url, variableData, thirdPath, requestMethod, getOnline);
if (response == null || response.getCode() != 200) return false;
} else {
if (asynResultList == null) asynResultList = new ArrayList<>(notVariableTextArray.length);
Future<String> result = POOL.submit(() -> {
GeneralMP3Data variableData = new GeneralMP3Data(data.getServer(), notVariableText,data.getPerson(),
data.getTone(), data.getBotname(), data.getCache(),data.getVolume(),data.getSpeed(),data.getPitch());
ResponseCodeWithData response = generalMP3(url, variableData, thirdPath, requestMethod, getOnline);
if (response == null || response.getCode() != 200) return false;
} else {
if (asynResultList == null) asynResultList = new ArrayList<>(notVariableTextArray.length);
Future<String> result = POOL.submit(() -> {
GeneralMP3Data variableData = new GeneralMP3Data(data.getServer(), notVariableText,data.getPerson(),
data.getTone(), data.getBotname(), data.getCache(),data.getVolume(),data.getSpeed(),data.getPitch());
ResponseCodeWithData response = generalMP3(url, variableData, thirdPath, requestMethod, getOnline);
if (response == null || response.getCode() != 200) return "0";
return "1";
});
asynResultList.add(result);
}
if (response == null || response.getCode() != 200) return "0";
return "1";
});
asynResultList.add(result);
}
notVariableTextPath = thirdPath;
} else {
return false;
}
notVariableTextPath = thirdPath;
// if (Initialize.getThirdPartyTts().contains(data.getPerson())) {
// } else {
// return false;
// }
}
combineMp3Text2FilePath.put(notVariableText, notVariableTextPath);
}
......
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