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
15d47443
Commit
15d47443
authored
Nov 07, 2020
by
苗权威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
11.07
parent
4675c212
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
26 additions
and
13 deletions
+26
-13
workspace.xml
.idea/workspace.xml
+0
-0
OkHttp3Utils.java
...ain/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
+3
-2
TTSConstants.java
...ain/java/ai/qiwu/com/tts_service/common/TTSConstants.java
+0
-2
TTSController.java
...ava/ai/qiwu/com/tts_service/controller/TTSController.java
+10
-5
TTService.java
.../main/java/ai/qiwu/com/tts_service/service/TTService.java
+13
-4
No files found.
.idea/workspace.xml
View file @
15d47443
This diff is collapsed.
Click to expand it.
tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
View file @
15d47443
...
...
@@ -272,13 +272,14 @@ public class OkHttp3Utils {
* @return 状态码
* @throws IOException
*/
public
static
Integer
doPostJsonStrReturnCode
(
String
url
,
String
requestJsonStr
)
throws
IOException
{
public
static
Integer
doPostJsonStrReturnCode
(
String
url
,
String
requestJsonStr
,
HashMap
<
String
,
String
>
headers
)
throws
IOException
{
Request
.
Builder
builder
=
new
Request
.
Builder
();
Request
request
=
builder
.
url
(
url
).
build
();
Headers
.
Builder
headBuilder
=
request
.
headers
().
newBuilder
();
headBuilder
.
add
(
"Content-Type"
,
"application/json; charset=utf-8"
);
Iterator
<
Map
.
Entry
<
String
,
String
>>
headIterator
=
headers
.
entrySet
().
iterator
();
headIterator
.
forEachRemaining
(
e
->
headBuilder
.
add
(
e
.
getKey
(),
e
.
getValue
()));
builder
.
headers
(
headBuilder
.
build
()).
post
(
RequestBody
.
create
(
MediaType
.
parse
(
"application/json; charset=utf-8"
),
requestJsonStr
));
Response
response
=
client
.
newCall
(
builder
.
build
()).
execute
();
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/common/TTSConstants.java
View file @
15d47443
...
...
@@ -39,8 +39,6 @@ public interface TTSConstants {
}
interface
TENCENT_AUDIO_ID
{
// String APP_ID = "2159149523";
// String App_Key_WITH_PREFIX = "&app_key=lqpqxEo6p2xQSILQ";
String
APP_ID
=
"2159448906"
;
String
App_Key_WITH_PREFIX
=
"&app_key=7Ab1JbKljViyyXhf"
;
}
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
View file @
15d47443
...
...
@@ -86,8 +86,11 @@ public class TTSController {
* @param response 响应信息
*/
@DeleteMapping
(
"/online_cache"
)
public
void
online_cache
(
@RequestBody
OnlineCache
onlineCache
,
HttpServletResponse
response
)
{
ttService
.
online_cache
(
onlineCache
,
response
);
public
void
online_cache
(
@RequestBody
OnlineCache
onlineCache
,
HttpServletResponse
response
,
HttpServletRequest
request
)
{
String
autho
=
request
.
getHeader
(
"Authorization"
);
String
groupId
=
request
.
getHeader
(
"groupId"
);
String
botAccount
=
request
.
getHeader
(
"botAccount"
);
ttService
.
online_cache
(
onlineCache
,
response
,
autho
,
groupId
,
botAccount
);
}
/**
...
...
@@ -303,7 +306,7 @@ public class TTSController {
data
.
setBitRate
(
bitRate
);
data
.
setSampleRate
(
StringUtils
.
isBlank
(
sampleRate
)
?
44100
:
Integer
.
parseInt
(
sampleRate
));
ttService
.
uploadOneSen
(
data
,
response
,
request
.
getHeader
(
"Authorization"
));
ttService
.
uploadOneSen
(
data
,
response
,
request
.
getHeader
(
"Authorization"
)
,
request
.
getHeader
(
"groupId"
),
request
.
getHeader
(
"botAccount"
)
);
}
@PutMapping
(
"/api/upload/record/one_sen"
)
...
...
@@ -436,8 +439,10 @@ public class TTSController {
*/
@DeleteMapping
(
"/api/delete/record/one_sen"
)
public
void
deleteOneSen
(
@RequestBody
UploadOneSenData
data
,
HttpServletResponse
response
,
HttpServletRequest
request
)
{
String
head
=
request
.
getHeader
(
"Authorization"
);
ttService
.
delOneSen
(
data
,
response
,
head
);
String
autho
=
request
.
getHeader
(
"Authorization"
);
String
groupId
=
request
.
getHeader
(
"groupId"
);
String
botAccount
=
request
.
getHeader
(
"botAccount"
);
ttService
.
delOneSen
(
data
,
response
,
autho
,
groupId
,
botAccount
);
}
@DeleteMapping
(
"/api/delete/one/audio"
)
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
View file @
15d47443
...
...
@@ -112,7 +112,7 @@ public class TTService {
* @param onlineCache 包括botname,sever服务器标识
* @param response 响应信息
*/
public
void
online_cache
(
OnlineCache
onlineCache
,
HttpServletResponse
response
)
{
public
void
online_cache
(
OnlineCache
onlineCache
,
HttpServletResponse
response
,
String
autho
,
String
groupId
,
String
botAccount
)
{
String
botName
=
onlineCache
.
getBotname
();
if
(
StringUtils
.
isBlank
(
botName
))
{
TTServiceUtil
.
buildOnlineCacheResponse
(
response
,
new
TTSResponse
(
401
,
"no botName"
),
401
);
...
...
@@ -164,7 +164,12 @@ public class TTService {
//deleteOfflineResCode = OkHttp3Utils.doPostReturnCode(Initialize.getDelCacheCallbackUrl(), new HashMap<>());
DelCacheCallbackUrlRequest
request
=
new
DelCacheCallbackUrlRequest
();
request
.
setBotname
(
botName
);
deleteOfflineResCode
=
OkHttp3Utils
.
doPostJsonStrReturnCode
(
Initialize
.
getDelCacheCallbackUrl
(),
JSON
.
toJSONString
(
request
));
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"Authorization"
,
autho
);
headers
.
put
(
"groupId"
,
groupId
);
headers
.
put
(
"botAccount"
,
botAccount
);
headers
.
put
(
"Content-Type"
,
"application/json; charset=utf-8"
);
deleteOfflineResCode
=
OkHttp3Utils
.
doPostJsonStrReturnCode
(
Initialize
.
getDelCacheCallbackUrl
(),
JSON
.
toJSONString
(
request
),
headers
);
if
(
deleteOfflineResCode
==
null
)
deleteOfflineResCode
=
556
;
}
}
catch
(
Exception
e
)
{
...
...
@@ -1633,7 +1638,7 @@ public class TTService {
* @param data 请求信息
* @param response 响应信息
*/
public
void
uploadOneSen
(
UploadOneSenData
data
,
HttpServletResponse
response
,
String
head
)
{
public
void
uploadOneSen
(
UploadOneSenData
data
,
HttpServletResponse
response
,
String
head
,
String
groupId
,
String
botAccount
)
{
// tid,botName,npcName,text,file皆不能为空,否则返回400
// log.info("UploadOneSenData:{}",data);
if
(
StringUtils
.
isAnyBlank
(
String
.
valueOf
(
data
.
getTid
()),
data
.
getBotName
(),
data
.
getNpcName
(),
data
.
getText
())
||
data
.
getFile
().
getName
()
==
null
)
{
...
...
@@ -1695,6 +1700,8 @@ public class TTService {
try
{
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"Authorization"
,
head
);
headers
.
put
(
"groupId"
,
groupId
);
headers
.
put
(
"botAccount"
,
botAccount
);
headers
.
put
(
"Content-Type"
,
"application/json; charset=utf-8"
);
// String jsonData = JSON.toJSONString(new int[]{data.getTid()});
// log.warn("getRecord_callback_url json data:{}, url:{}",jsonData, Initialize.getRecord_callback_url());
...
...
@@ -2240,7 +2247,7 @@ public class TTService {
* @param data
* @param response
*/
public
void
delOneSen
(
UploadOneSenData
data
,
HttpServletResponse
response
,
String
head
)
{
public
void
delOneSen
(
UploadOneSenData
data
,
HttpServletResponse
response
,
String
head
,
String
groupId
,
String
botAccount
)
{
// 四个参数都不能为空
if
(
StringUtils
.
isAnyBlank
(
data
.
getBotName
(),
data
.
getNpcName
(),
data
.
getText
())
||
data
.
getTid
()
==
null
)
{
TTServiceUtil
.
buildUploadResponse
(
response
,
new
TTSResponse
(
400
,
"参数不对"
),
400
);
...
...
@@ -2267,6 +2274,8 @@ public class TTService {
try
{
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
headers
.
put
(
"Authorization"
,
head
);
headers
.
put
(
"groupId"
,
groupId
);
headers
.
put
(
"botAccount"
,
botAccount
);
headers
.
put
(
"Content-Type"
,
"application/json; charset=utf-8"
);
String
tid
;
if
(
Boolean
.
TRUE
.
equals
(
data
.
getCustomText
()))
{
...
...
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