Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
SmartBox
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
苗权威
SmartBox
Commits
46b40227
Commit
46b40227
authored
Nov 29, 2019
by
苗权威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11.29
parent
f64a2e4c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
44 additions
and
27 deletions
+44
-27
compiler.xml
.idea/compiler.xml
+1
-1
workspace.xml
.idea/workspace.xml
+0
-0
CallPython.java
.../main/java/ai/qiwu/com/tts_service/common/CallPython.java
+1
-1
TTSUtils.java
...rc/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
+24
-18
Test.java
...e/src/main/java/ai/qiwu/com/tts_service/service/Test.java
+3
-7
XiaoDuHomeController.java
.../qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
+10
-0
RequestTerminal.java
...ai/qiwu/com/xiaoduhome/xiaoai/common/RequestTerminal.java
+1
-0
XiaoAiConstants.java
...ai/qiwu/com/xiaoduhome/xiaoai/common/XiaoAiConstants.java
+2
-0
XiaoAiService.java
.../ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiService.java
+2
-0
No files found.
.idea/compiler.xml
View file @
46b40227
...
...
@@ -33,7 +33,7 @@
<module
name=
"open"
options=
"-parameters"
/>
<module
name=
"rokid"
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=
"tts_offline"
options=
"-parameters"
/>
<module
name=
"tts_service"
options=
"-parameters"
/>
...
...
.idea/workspace.xml
View file @
46b40227
This diff is collapsed.
Click to expand it.
tts_service/src/main/java/ai/qiwu/com/tts_service/common/CallPython.java
View file @
46b40227
...
...
@@ -83,7 +83,7 @@ public class CallPython {
* @param arg sox命令
* @return 执行结果
*/
p
rivate
static
String
execute
(
String
arg
)
{
p
ublic
static
String
execute
(
String
arg
)
{
ProcessBuilder
processBuilder
=
new
ProcessBuilder
(
arg
.
split
(
" "
));
processBuilder
.
redirectErrorStream
(
true
);
//错误输出流合并到标准输出流中
StringBuilder
builder
=
new
StringBuilder
();
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSUtils.java
View file @
46b40227
...
...
@@ -493,24 +493,30 @@ public class TTSUtils {
}
catch
(
Exception
e
)
{
log
.
error
(
"转换采样率出现错误:{}"
,
e
);
}
try
(
BufferedOutputStream
outputStream
=
new
BufferedOutputStream
(
new
FileOutputStream
(
new
File
(
targetFilepath
)))){
AudioEnumeration
<
InputStream
>
audioEnumeration
=
new
AudioEnumeration
<>();
for
(
String
filepath
:
filePathList
)
{
// log.warn(filepath);
if
(
filepath
.
equals
(
Initialize
.
getThirdParty
()))
{
continue
;
}
audioEnumeration
.
add
(
new
FileInputStream
(
new
File
(
filepath
)));
}
SequenceInputStream
sequenceInputStream
=
new
SequenceInputStream
(
audioEnumeration
);
byte
[]
buf
=
new
byte
[
1024
];
int
ln
;
while
((
ln
=
sequenceInputStream
.
read
(
buf
))
!=
-
1
)
{
outputStream
.
write
(
buf
,
0
,
ln
);
}
outputStream
.
flush
();
sequenceInputStream
.
close
();
}
// String command = "sox "+ StringUtils.join(filePathList, " ");
filePathList
.
add
(
targetFilepath
);
CallPython
.
execute
(
"sox "
+
StringUtils
.
join
(
filePathList
,
" "
));
// try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(new File(targetFilepath), true))){
// AudioEnumeration<InputStream> audioEnumeration = new AudioEnumeration<>();
// for (String filepath : filePathList) {
//// log.warn(filepath);
// if (filepath.equals(Initialize.getThirdParty())) {
// continue;
// }
// audioEnumeration.add(new FileInputStream(new File(filepath)));
// }
// SequenceInputStream sequenceInputStream= new SequenceInputStream(audioEnumeration);
// 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
);
TTService
.
POOL
.
submit
(()
->
{
for
(
String
path:
check
)
{
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/service/Test.java
View file @
46b40227
...
...
@@ -282,13 +282,9 @@ public class Test {
list
.
add
(
"/home/yf01/下载/human2.mp3"
);
list
.
add
(
"/home/yf01/下载/us1.mp3"
);
list
.
add
(
"/home/yf01/下载/us2.mp3"
);
// TTSUtils.combineMp3File(list, "/home/yf01/下载/targetss
.mp3");
TTSUtils
.
combineMp3File
(
list
,
"/home/yf01/下载/mqwTest
.mp3"
);
try
{
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
){}
System
.
out
.
println
(
TTSUtils
.
buildMP3Filename
(
"你当{/dang1/}前{/qian2/}分{/fen1/}数{/shu4/}是"
));
System
.
out
.
println
(
TTSUtils
.
buildMP3Filename
(
"10"
));
}
}
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
View file @
46b40227
...
...
@@ -55,6 +55,16 @@ public class XiaoDuHomeController {
// 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"
)
public
String
chat
()
{
try
{
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/common/RequestTerminal.java
View file @
46b40227
...
...
@@ -35,6 +35,7 @@ public class RequestTerminal {
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"Content-Type"
,
"application/json;charset=utf-8"
);
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"
);
String
resStr
;
if
(
userId
.
equals
(
XiaoAiService
.
deviceId
))
{
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/common/XiaoAiConstants.java
View file @
46b40227
...
...
@@ -23,8 +23,10 @@ public interface XiaoAiConstants {
interface
TTS
{
String
WELCOME_WORD
=
"欢迎来到交游天下,海量的作品在这等您"
;
String
WELCOME_WORD_CHILD
=
"小朋友你好,欢迎来到智能故事"
;
String
WELCOME_WORD_Adult
=
"你好,欢迎来到智能小说"
;
String
END_BYE
=
"我们的作品库在不断扩充,欢迎再来玩"
;
String
END_BYE_CHILD
=
"再见啦小朋友,记得下次再来玩哦"
;
String
END_BYE_Adult
=
"再见啦,记得下次再来玩哦"
;
String
END_WORD
=
"退出"
;
String
USER_IDLE
=
"小悟在等你的回复"
;
String
ANOTHER_USER_IDLE
=
"再不回复我,那我可退出喽"
;
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/service/XiaoAiService.java
View file @
46b40227
...
...
@@ -180,6 +180,7 @@ public class XiaoAiService {
LAST_OUTTIME_RESULT
.
remove
(
getUserId
(
request
));
LAST_OUTTIME_MARK
.
remove
(
getUserId
(
request
));
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
);
}
...
...
@@ -269,6 +270,7 @@ public class XiaoAiService {
LAST_OUTTIME_MARK
.
remove
(
userId
);
LAST_OUTTIME_RESULT
.
remove
(
userId
);
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
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment