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
b3beb8bf
Commit
b3beb8bf
authored
Jan 15, 2021
by
苗权威
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
http://192.168.1.81:8000/Foxes/SmartBox
parents
397c4fda
3d3ba9d2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
6 deletions
+33
-6
TTServiceEdition2.java
...va/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
+5
-0
ThirdPartyService.java
...qiwu/com/tts_service/service/baidu/ThirdPartyService.java
+19
-4
OkHttp3Utils.java
...main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
+1
-1
RequestTerminal.java
...ai/qiwu/com/xiaoduhome/xiaoai/common/RequestTerminal.java
+8
-1
No files found.
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
View file @
b3beb8bf
...
@@ -1008,6 +1008,7 @@ public class TTServiceEdition2 {
...
@@ -1008,6 +1008,7 @@ public class TTServiceEdition2 {
// 代码作用是替换标音符号,讯非标音要求查看讯非文档
// 代码作用是替换标音符号,讯非标音要求查看讯非文档
// http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=15340
// http://bbs.xfyun.cn/forum.php?mod=viewthread&tid=15340
StringBuilder
temp
=
new
StringBuilder
();
StringBuilder
temp
=
new
StringBuilder
();
temp
.
append
(
"<?xml version=\"1.0\" encoding=\"GB2312\"?><speak>"
);
int
sliceStart
=
0
;
int
sliceStart
=
0
;
for
(
int
i
=
0
;
i
<
text
.
length
()-
1
;
i
++)
{
for
(
int
i
=
0
;
i
<
text
.
length
()-
1
;
i
++)
{
if
(
text
.
charAt
(
i
)
==
'{'
&&
text
.
charAt
(
i
+
1
)
==
'/'
)
{
if
(
text
.
charAt
(
i
)
==
'{'
&&
text
.
charAt
(
i
+
1
)
==
'/'
)
{
...
@@ -1043,6 +1044,7 @@ public class TTServiceEdition2 {
...
@@ -1043,6 +1044,7 @@ public class TTServiceEdition2 {
if
(
sliceStart
<
text
.
length
())
{
if
(
sliceStart
<
text
.
length
())
{
temp
.
append
(
text
.
substring
(
sliceStart
));
temp
.
append
(
text
.
substring
(
sliceStart
));
}
}
temp
.
append
(
"</speak>"
);
text
=
temp
.
toString
();
text
=
temp
.
toString
();
}
else
{
}
else
{
text
=
text
.
replaceAll
(
"\\{/"
,
"[="
);
text
=
text
.
replaceAll
(
"\\{/"
,
"[="
);
...
@@ -1139,6 +1141,9 @@ public class TTServiceEdition2 {
...
@@ -1139,6 +1141,9 @@ public class TTServiceEdition2 {
// return new ResponseCodeWithData(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "文本标音不正确");
// return new ResponseCodeWithData(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "文本标音不正确");
return
null
;
return
null
;
}
}
if
(!
Character
.
isDigit
(
mark
.
charAt
(
mark
.
length
()-
1
)))
{
mark
=
mark
+
"5"
;
}
temp
.
append
(
text
,
sliceStart
,
j
).
append
(
"<phoneme alphabet=\"py\" ph=\""
).
append
(
mark
).
append
(
"\">"
).
append
(
text
.
charAt
(
j
)).
append
(
"</phoneme>"
);
temp
.
append
(
text
,
sliceStart
,
j
).
append
(
"<phoneme alphabet=\"py\" ph=\""
).
append
(
mark
).
append
(
"\">"
).
append
(
text
.
charAt
(
j
)).
append
(
"</phoneme>"
);
for
(;
markEnd
<
text
.
length
();
markEnd
++)
{
for
(;
markEnd
<
text
.
length
();
markEnd
++)
{
if
(
text
.
charAt
(
markEnd
)
==
'}'
)
{
if
(
text
.
charAt
(
markEnd
)
==
'}'
)
{
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/service/baidu/ThirdPartyService.java
View file @
b3beb8bf
...
@@ -93,8 +93,8 @@ public class ThirdPartyService {
...
@@ -93,8 +93,8 @@ public class ThirdPartyService {
*/
*/
public
static
boolean
thirdPartyCall
(
String
text
,
String
per
,
String
filepath
,
String
person
)
{
public
static
boolean
thirdPartyCall
(
String
text
,
String
per
,
String
filepath
,
String
person
)
{
// person = getThirdPartyName(person);
// person = getThirdPartyName(person);
p
erson
=
person
.
substring
(
0
,
5
);
String
subP
erson
=
person
.
substring
(
0
,
5
);
switch
(
p
erson
)
{
switch
(
subP
erson
)
{
// 文本小于2048个中文字或者英文数字
// 文本小于2048个中文字或者英文数字
case
"Baidu"
:
{
case
"Baidu"
:
{
return
synthesis
(
text
,
Integer
.
parseInt
(
per
),
filepath
);
return
synthesis
(
text
,
Integer
.
parseInt
(
per
),
filepath
);
...
@@ -115,7 +115,7 @@ public class ThirdPartyService {
...
@@ -115,7 +115,7 @@ public class ThirdPartyService {
// 最大长度需小于8000字节,约2000汉字
// 最大长度需小于8000字节,约2000汉字
case
"XunFe"
:
{
case
"XunFe"
:
{
try
{
try
{
return
xunFeiTTS
(
per
,
text
,
filepath
);
return
xunFeiTTS
(
per
,
text
,
filepath
,
person
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"xunFeiTTS error:{}, text:{}, filepath:{}"
,
e
,
text
,
filepath
);
log
.
error
(
"xunFeiTTS error:{}, text:{}, filepath:{}"
,
e
,
text
,
filepath
);
return
false
;
return
false
;
...
@@ -348,7 +348,7 @@ public class ThirdPartyService {
...
@@ -348,7 +348,7 @@ public class ThirdPartyService {
// ============== XUN FEI ===================
// ============== XUN FEI ===================
private
static
boolean
xunFeiTTS
(
String
per
,
String
text
,
String
filepath
)
throws
Exception
{
private
static
boolean
xunFeiTTS
(
String
per
,
String
text
,
String
filepath
,
String
person
)
throws
Exception
{
// 构建鉴权url
// 构建鉴权url
// String authUrl = getAuthUrl();
// String authUrl = getAuthUrl();
//将url中的 schema http://和https://分别替换为ws:// 和 wss://
//将url中的 schema http://和https://分别替换为ws:// 和 wss://
...
@@ -380,6 +380,21 @@ public class ThirdPartyService {
...
@@ -380,6 +380,21 @@ public class ThirdPartyService {
//填充business
//填充business
XunFeiRequestDataBusiness
business
=
audioRequest
.
getBusiness
();
XunFeiRequestDataBusiness
business
=
audioRequest
.
getBusiness
();
business
.
setVcn
(
per
);
business
.
setVcn
(
per
);
if
(
Initialize
.
xunfeiUseSSMLPerson
.
contains
(
person
))
{
try
{
audioRequest
.
getData
().
setText
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
"GBK"
)));
}
catch
(
UnsupportedEncodingException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
audioRequest
.
getData
().
setText
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
)));
}
}
else
{
//填充data
audioRequest
.
getData
().
setText
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
)));
//使用小语种须使用下面的代码,此处的unicode指的是 utf16小端的编码方式,即"UTF-16LE"”
//data.addProperty("text", Base64.getEncoder().encodeToString(text.getBytes("UTF-16LE")));
}
//填充data
//填充data
audioRequest
.
getData
().
setText
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
)));
audioRequest
.
getData
().
setText
(
Base64
.
getEncoder
().
encodeToString
(
text
.
getBytes
(
StandardCharsets
.
UTF_8
)));
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/OkHttp3Utils.java
View file @
b3beb8bf
...
@@ -124,7 +124,7 @@ public class OkHttp3Utils {
...
@@ -124,7 +124,7 @@ public class OkHttp3Utils {
urlBuild
.
addQueryParameter
(
"uid"
,
uid
);
urlBuild
.
addQueryParameter
(
"uid"
,
uid
);
builder
.
headers
(
headBuilder
.
build
()).
post
(
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
requestJsonStr
));
builder
.
url
(
urlBuild
.
build
()).
headers
(
headBuilder
.
build
()).
post
(
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
requestJsonStr
));
Response
response
=
client
.
newCall
(
builder
.
build
()).
execute
();
Response
response
=
client
.
newCall
(
builder
.
build
()).
execute
();
try
(
ResponseBody
body
=
response
.
body
()){
try
(
ResponseBody
body
=
response
.
body
()){
return
body
.
string
();
return
body
.
string
();
...
...
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/xiaoai/common/RequestTerminal.java
View file @
b3beb8bf
...
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
...
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.HashMap
;
/**
/**
...
@@ -98,7 +99,13 @@ public class RequestTerminal {
...
@@ -98,7 +99,13 @@ public class RequestTerminal {
requestPojo
.
setUid
(
userId
);
requestPojo
.
setUid
(
userId
);
requestPojo
.
setMsg
(
XiaoAiConstants
.
TTS
.
END_WORD
);
requestPojo
.
setMsg
(
XiaoAiConstants
.
TTS
.
END_WORD
);
String
requestJsonStr
=
JSON
.
toJSONString
(
requestPojo
);
String
requestJsonStr
=
JSON
.
toJSONString
(
requestPojo
);
OkHttp3Utils
.
xiaoaiBackPostAsync
(
ScheduleServiceNew
.
BASE_HOST_URL
+
"?uid="
+
userId
,
requestJsonStr
,
type
);
String
uid
=
userId
;
try
{
uid
=
URLEncoder
.
encode
(
userId
,
"UTF-8"
);
}
catch
(
Exception
e
)
{
uid
=
userId
;
}
OkHttp3Utils
.
xiaoaiBackPostAsync
(
ScheduleServiceNew
.
BASE_HOST_URL
+
"?uid="
+
uid
,
requestJsonStr
,
type
);
// if (userId.equals(XiaoAiService.deviceId)) {
// if (userId.equals(XiaoAiService.deviceId)) {
// OkHttp3Utils.backPostAsync(XiaoAiConstants.QI_WU_TERMINATE_DIDI, requestJsonStr, type);
// OkHttp3Utils.backPostAsync(XiaoAiConstants.QI_WU_TERMINATE_DIDI, requestJsonStr, type);
// }else {
// }else {
...
...
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