From 01a79d5b431b71cc79cf5f6cc92cd4f3432781dd Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期二, 30 四月 2024 12:39:54 +0800 Subject: [PATCH] 代码提交 --- smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java | 25 +++++++++++++++---------- 1 files changed, 15 insertions(+), 10 deletions(-) diff --git a/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java index 95fab99..bb250b5 100644 --- a/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java +++ b/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java @@ -18,6 +18,7 @@ import com.aliyun.teautil.Common; import com.aliyun.teautil.models.RuntimeOptions; import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.uuid.IdUtils; import com.smartor.domain.*; import com.smartor.mapper.*; @@ -90,9 +91,9 @@ } @Override - public String texttospeech(String textspeech) { + public String texttospeech(String textspeech, String filePath) { this.accessToken(); - this.process2(textspeech); + this.process2(textspeech, filePath); client.shutdown(); return returnResult; } @@ -163,11 +164,11 @@ if (spans.size() != 0) { Elements radio__type = spans.get(0).getElementsByClass("radio__type"); if (radio__type.size() != 0) { - svyLibTopic.setTopictype(1L); + svyLibTopic.setTopictype("1"); } else { Elements checkbox__type = spans.get(0).getElementsByClass("checkbox__type"); if (checkbox__type.size() != 0) { - svyLibTopic.setTopictype(2L); + svyLibTopic.setTopictype("2"); } } @@ -224,7 +225,7 @@ svyLibTopic2.setTopic(legend); svyLibTopic2.setDelFlag("0"); svyLibTopic.setIsupload(0L); - svyLibTopic2.setTopictype(4L); + svyLibTopic2.setTopictype("4"); svyLibTopic2.setOrgid(fileName); try { svyLibTopicMapper.insertSvyLibTopic(svyLibTopic2); @@ -259,7 +260,7 @@ svyLibTopic3.setTopic(legend); svyLibTopic3.setDelFlag("0"); svyLibTopic3.setIsupload(0L); - svyLibTopic3.setTopictype(3L); + svyLibTopic3.setTopictype("3"); svyLibTopic3.setOrgid(fileName); try { svyLibTopicMapper.insertSvyLibTopic(svyLibTopic3); @@ -399,11 +400,15 @@ } - private SpeechSynthesizerListener getSynthesizerListener() { + private SpeechSynthesizerListener getSynthesizerListener(String filePath) { SpeechSynthesizerListener listener = null; try { + if (StringUtils.isEmpty(filePath)) { + filePath = "tts_test.wav"; + } + String finalFilePath = filePath; listener = new SpeechSynthesizerListener() { - File f = new File("tts_test.wav"); + File f = new File(finalFilePath); FileOutputStream fout = new FileOutputStream(f); private boolean firstRecvBinary = true; @@ -449,11 +454,11 @@ } - public void process2(String text) { + public void process2(String text, String filePath) { SpeechSynthesizer synthesizer = null; try { //鍒涘缓瀹炰緥锛屽缓绔嬭繛鎺ャ�� - synthesizer = new SpeechSynthesizer(client, getSynthesizerListener()); + synthesizer = new SpeechSynthesizer(client, getSynthesizerListener(filePath)); synthesizer.setAppKey(appKey); //璁剧疆杩斿洖闊抽鐨勭紪鐮佹牸寮� synthesizer.setFormat(OutputFormatEnum.WAV); -- Gitblit v1.9.3