Commit f79a08da47dc84bd99c5d7944d279ac51755e2b6
Merge remote-tracking branch 'origin/lggj' into lggj
Showing
2 changed files
with
22 additions
and
10 deletions
src/main/java/com/bsth/service/impl/StationRouteServiceImpl.java
| ... | ... | @@ -436,11 +436,11 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 436 | 436 | List<LineRegion> lineRegions = lineRegionRepository.findAll(new CustomerSpecs<>(param)); |
| 437 | 437 | if (objects.size()>0) { |
| 438 | 438 | // 报站音频 |
| 439 | - Set<String> languages = new HashSet<>(); | |
| 440 | - languages.add("cn"); | |
| 441 | - languages.add("sh"); | |
| 442 | - languages.add("en"); | |
| 443 | - InputStream tts = ttsAndZip(objects, line, languages); | |
| 439 | +// Set<String> languages = new HashSet<>(); | |
| 440 | +// languages.add("cn"); | |
| 441 | +// languages.add("sh"); | |
| 442 | +// languages.add("en"); | |
| 443 | +// InputStream tts = ttsAndZip(objects, line, languages); | |
| 444 | 444 | /** 获取配置文件里的ftp登录参数 */ |
| 445 | 445 | Map<String, Object> FTPParamMap = readPropertiesGetFTPParam(); |
| 446 | 446 | // 压缩文件名 |
| ... | ... | @@ -519,8 +519,8 @@ public class StationRouteServiceImpl extends BaseServiceImpl<StationRoute, Integ |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | |
| 522 | - clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode())); | |
| 523 | - clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode()), tts); | |
| 522 | +// clientUtils.deleteFtpFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode())); | |
| 523 | +// clientUtils.uploadFile(url, port, username, password, remotePath + "/voice/", String.format("%s.zip", line.getLineCode()), tts); | |
| 524 | 524 | |
| 525 | 525 | resultMap.put("status", ResponseCode.SUCCESS); |
| 526 | 526 | }else { | ... | ... |
src/main/java/com/bsth/util/IFlyUtils.java
| ... | ... | @@ -37,6 +37,10 @@ public class IFlyUtils { |
| 37 | 37 | * @param text |
| 38 | 38 | */ |
| 39 | 39 | public static void textToSpeechCn(String text, String outputPath) throws Exception { |
| 40 | + File file = new File(outputPath); | |
| 41 | + if (!file.getParentFile().exists()) { | |
| 42 | + file.getParentFile().mkdirs(); | |
| 43 | + } | |
| 40 | 44 | String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); |
| 41 | 45 | SpeechRequest request = new SpeechRequest(); |
| 42 | 46 | request.getCommon().put("app_id", appId); |
| ... | ... | @@ -45,7 +49,7 @@ public class IFlyUtils { |
| 45 | 49 | request.getBusiness().put("vcn", "x4_lingxiaoshan_profnews"); |
| 46 | 50 | request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes("GBK"))); |
| 47 | 51 | request.getData().put("status", 2); |
| 48 | - websocketWork(wsUrl, request, new FileOutputStream(outputPath)); | |
| 52 | + websocketWork(wsUrl, request, new FileOutputStream(file)); | |
| 49 | 53 | while (!request.isCompleted()) { |
| 50 | 54 | Thread.sleep(500); |
| 51 | 55 | } |
| ... | ... | @@ -57,6 +61,10 @@ public class IFlyUtils { |
| 57 | 61 | * @param text |
| 58 | 62 | */ |
| 59 | 63 | public static void textToSpeechSh(String text, String outputPath) throws Exception { |
| 64 | + File file = new File(outputPath); | |
| 65 | + if (!file.getParentFile().exists()) { | |
| 66 | + file.getParentFile().mkdirs(); | |
| 67 | + } | |
| 60 | 68 | String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); |
| 61 | 69 | SpeechRequest request = new SpeechRequest(); |
| 62 | 70 | request.getCommon().put("app_id", appId); |
| ... | ... | @@ -65,7 +73,7 @@ public class IFlyUtils { |
| 65 | 73 | request.getBusiness().put("vcn", "x3_ziling"); |
| 66 | 74 | request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes("GBK"))); |
| 67 | 75 | request.getData().put("status", 2); |
| 68 | - websocketWork(wsUrl, request, new FileOutputStream(outputPath)); | |
| 76 | + websocketWork(wsUrl, request, new FileOutputStream(file)); | |
| 69 | 77 | while (!request.isCompleted()) { |
| 70 | 78 | Thread.sleep(500); |
| 71 | 79 | } |
| ... | ... | @@ -77,6 +85,10 @@ public class IFlyUtils { |
| 77 | 85 | * @param text |
| 78 | 86 | */ |
| 79 | 87 | public static void textToSpeechEn(String text, String outputPath) throws Exception { |
| 88 | + File file = new File(outputPath); | |
| 89 | + if (!file.getParentFile().exists()) { | |
| 90 | + file.getParentFile().mkdirs(); | |
| 91 | + } | |
| 80 | 92 | String wsUrl = getAuthUrl("https://tts-api.xfyun.cn/v2/tts", apiKey, apiSecret).replace("https://", "wss://"); |
| 81 | 93 | SpeechRequest request = new SpeechRequest(); |
| 82 | 94 | request.getCommon().put("app_id", appId); |
| ... | ... | @@ -85,7 +97,7 @@ public class IFlyUtils { |
| 85 | 97 | request.getBusiness().put("vcn", "x4_enus_luna_assist"); |
| 86 | 98 | request.getData().put("text", Base64.getEncoder().encodeToString(text.replace(",", "[p1000]").getBytes(StandardCharsets.UTF_8))); |
| 87 | 99 | request.getData().put("status", 2); |
| 88 | - websocketWork(wsUrl, request, new FileOutputStream(outputPath)); | |
| 100 | + websocketWork(wsUrl, request, new FileOutputStream(file)); | |
| 89 | 101 | while (!request.isCompleted()) { |
| 90 | 102 | Thread.sleep(500); |
| 91 | 103 | } | ... | ... |