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
87733188
Commit
87733188
authored
Jan 14, 2021
by
李进峰
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
讯飞SSML标记修改,添加默认读音
parent
4c433f5e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
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
No files found.
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
View file @
87733188
...
@@ -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 @
87733188
...
@@ -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
)));
...
...
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