Commit 46b40227 by 苗权威

11.29

parent f64a2e4c
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
<module name="open" options="-parameters" /> <module name="open" options="-parameters" />
<module name="rokid" options="-parameters" /> <module name="rokid" options="-parameters" />
<module name="ruoqi" options="-parameters" /> <module name="ruoqi" options="-parameters" />
<module name="spirit" options="-parameters -extdirs $PROJECT_DIR$/spirit/src/main/resources/lib" /> <module name="spirit" options="-parameters -extdirs /usr/local/intellij/workplace/smartbox/spirit/src/main/resources/lib" />
<module name="third_party_load" options="-parameters" /> <module name="third_party_load" options="-parameters" />
<module name="tts_offline" options="-parameters" /> <module name="tts_offline" options="-parameters" />
<module name="tts_service" options="-parameters" /> <module name="tts_service" options="-parameters" />
......
...@@ -83,7 +83,7 @@ public class CallPython { ...@@ -83,7 +83,7 @@ public class CallPython {
* @param arg sox命令 * @param arg sox命令
* @return 执行结果 * @return 执行结果
*/ */
private static String execute(String arg) { public static String execute(String arg) {
ProcessBuilder processBuilder = new ProcessBuilder(arg.split(" ")); ProcessBuilder processBuilder = new ProcessBuilder(arg.split(" "));
processBuilder.redirectErrorStream(true); //错误输出流合并到标准输出流中 processBuilder.redirectErrorStream(true); //错误输出流合并到标准输出流中
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
......
...@@ -493,24 +493,30 @@ public class TTSUtils { ...@@ -493,24 +493,30 @@ public class TTSUtils {
} catch (Exception e) { } catch (Exception e) {
log.error("转换采样率出现错误:{}",e); log.error("转换采样率出现错误:{}",e);
} }
try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(new File(targetFilepath)))){
AudioEnumeration<InputStream> audioEnumeration = new AudioEnumeration<>();
for (String filepath : filePathList) { // String command = "sox "+ StringUtils.join(filePathList, " ");
// log.warn(filepath); filePathList.add(targetFilepath);
if (filepath.equals(Initialize.getThirdParty())) { CallPython.execute("sox "+ StringUtils.join(filePathList, " "));
continue;
} // try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(new File(targetFilepath), true))){
audioEnumeration.add(new FileInputStream(new File(filepath))); // AudioEnumeration<InputStream> audioEnumeration = new AudioEnumeration<>();
} // for (String filepath : filePathList) {
SequenceInputStream sequenceInputStream= new SequenceInputStream(audioEnumeration); //// log.warn(filepath);
byte[] buf = new byte[1024]; // if (filepath.equals(Initialize.getThirdParty())) {
int ln; // continue;
while ((ln = sequenceInputStream.read(buf)) != -1) { // }
outputStream.write(buf, 0, ln); // audioEnumeration.add(new FileInputStream(new File(filepath)));
} // }
outputStream.flush(); // SequenceInputStream sequenceInputStream= new SequenceInputStream(audioEnumeration);
sequenceInputStream.close(); // byte[] buf = new byte[1024];
} // int ln;
// while ((ln = sequenceInputStream.read(buf)) != -1) {
// outputStream.write(buf, 0, ln);
// }
// outputStream.flush();
// sequenceInputStream.close();
// }
final List<String> check = new ArrayList<>(filePathList); final List<String> check = new ArrayList<>(filePathList);
TTService.POOL.submit(() -> { TTService.POOL.submit(() -> {
for (String path: check) { for (String path: check) {
......
...@@ -282,13 +282,9 @@ public class Test { ...@@ -282,13 +282,9 @@ public class Test {
list.add("/home/yf01/下载/human2.mp3"); list.add("/home/yf01/下载/human2.mp3");
list.add("/home/yf01/下载/us1.mp3"); list.add("/home/yf01/下载/us1.mp3");
list.add("/home/yf01/下载/us2.mp3"); list.add("/home/yf01/下载/us2.mp3");
// TTSUtils.combineMp3File(list, "/home/yf01/下载/targetss.mp3"); TTSUtils.combineMp3File(list, "/home/yf01/下载/mqwTest.mp3");
try { System.out.println(TTSUtils.buildMP3Filename("你当{/dang1/}前{/qian2/}分{/fen1/}数{/shu4/}是"));
System.out.println(TTSUtils.buildMP3Filename("10"));
File[] files = new File("/home/yf01/下载/tts").listFiles((dir, name) -> !name.equals("test"));
for (File file: files) System.out.println(file.getName());
System.out.println(files.length);
} catch (Exception e){}
} }
} }
...@@ -55,6 +55,16 @@ public class XiaoDuHomeController { ...@@ -55,6 +55,16 @@ public class XiaoDuHomeController {
// return xiaoAiService.getResponse(request); // return xiaoAiService.getResponse(request);
} }
@RequestMapping("/xiaoai/adult")
public XiaoAiResponse xiaoaiAdult(@RequestBody XiaoAiRequest request) {
//log.info("请求:"+request);
request.setType(2);
XiaoAiResponse response = xiaoAiService.getResponse(request);
// log.info("响应:"+response);
return response;
// return xiaoAiService.getResponse(request);
}
@RequestMapping("/xiaoduhome/chat") @RequestMapping("/xiaoduhome/chat")
public String chat() { public String chat() {
try { try {
......
...@@ -35,6 +35,7 @@ public class RequestTerminal { ...@@ -35,6 +35,7 @@ public class RequestTerminal {
HashMap<String, String> headers = new HashMap<>(); HashMap<String, String> headers = new HashMap<>();
headers.put("Content-Type", "application/json;charset=utf-8"); headers.put("Content-Type", "application/json;charset=utf-8");
if (NumberUtils.INTEGER_ONE.equals(type)) headers.put("App-Channel-Id", "jiaoyou-audio-child-test"); if (NumberUtils.INTEGER_ONE.equals(type)) headers.put("App-Channel-Id", "jiaoyou-audio-child-test");
else if (NumberUtils.INTEGER_TWO.equals(type)) headers.put("App-Channel-Id", "jiaoyou-audio-adult-test");
else headers.put("App-Channel-Id", "jiaoyou-audio-test"); else headers.put("App-Channel-Id", "jiaoyou-audio-test");
String resStr; String resStr;
if (userId.equals(XiaoAiService.deviceId)) { if (userId.equals(XiaoAiService.deviceId)) {
......
...@@ -23,8 +23,10 @@ public interface XiaoAiConstants { ...@@ -23,8 +23,10 @@ public interface XiaoAiConstants {
interface TTS { interface TTS {
String WELCOME_WORD = "欢迎来到交游天下,海量的作品在这等您"; String WELCOME_WORD = "欢迎来到交游天下,海量的作品在这等您";
String WELCOME_WORD_CHILD = "小朋友你好,欢迎来到智能故事"; String WELCOME_WORD_CHILD = "小朋友你好,欢迎来到智能故事";
String WELCOME_WORD_Adult = "你好,欢迎来到智能小说";
String END_BYE = "我们的作品库在不断扩充,欢迎再来玩"; String END_BYE = "我们的作品库在不断扩充,欢迎再来玩";
String END_BYE_CHILD = "再见啦小朋友,记得下次再来玩哦"; String END_BYE_CHILD = "再见啦小朋友,记得下次再来玩哦";
String END_BYE_Adult = "再见啦,记得下次再来玩哦";
String END_WORD = "退出"; String END_WORD = "退出";
String USER_IDLE = "小悟在等你的回复"; String USER_IDLE = "小悟在等你的回复";
String ANOTHER_USER_IDLE = "再不回复我,那我可退出喽"; String ANOTHER_USER_IDLE = "再不回复我,那我可退出喽";
......
...@@ -180,6 +180,7 @@ public class XiaoAiService { ...@@ -180,6 +180,7 @@ public class XiaoAiService {
LAST_OUTTIME_RESULT.remove(getUserId(request)); LAST_OUTTIME_RESULT.remove(getUserId(request));
LAST_OUTTIME_MARK.remove(getUserId(request)); LAST_OUTTIME_MARK.remove(getUserId(request));
if (NumberUtils.INTEGER_ONE.equals(request.getType())) return buildTextResponse(XiaoAiConstants.TTS.WELCOME_WORD_CHILD); if (NumberUtils.INTEGER_ONE.equals(request.getType())) return buildTextResponse(XiaoAiConstants.TTS.WELCOME_WORD_CHILD);
else if (NumberUtils.INTEGER_TWO.equals(request.getType())) return buildTextResponse(XiaoAiConstants.TTS.WELCOME_WORD_Adult);
return buildTextResponse(XiaoAiConstants.TTS.WELCOME_WORD); return buildTextResponse(XiaoAiConstants.TTS.WELCOME_WORD);
} }
...@@ -269,6 +270,7 @@ public class XiaoAiService { ...@@ -269,6 +270,7 @@ public class XiaoAiService {
LAST_OUTTIME_MARK.remove(userId); LAST_OUTTIME_MARK.remove(userId);
LAST_OUTTIME_RESULT.remove(userId); LAST_OUTTIME_RESULT.remove(userId);
if (NumberUtils.INTEGER_ONE.equals(type)) return buildTextResponse(XiaoAiConstants.TTS.END_BYE_CHILD); if (NumberUtils.INTEGER_ONE.equals(type)) return buildTextResponse(XiaoAiConstants.TTS.END_BYE_CHILD);
else if (NumberUtils.INTEGER_TWO.equals(type)) return buildTextResponse(XiaoAiConstants.TTS.END_BYE_Adult);
return buildTextResponse(XiaoAiConstants.TTS.END_BYE); return buildTextResponse(XiaoAiConstants.TTS.END_BYE);
} }
......
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