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
7f085a36
Commit
7f085a36
authored
Sep 30, 2020
by
苗权威
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
09.30
parent
ee773023
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
32 deletions
+26
-32
workspace.xml
.idea/workspace.xml
+0
-0
ApachHttpUtils.java
...n/java/ai/qiwu/com/tts_service/common/ApachHttpUtils.java
+4
-4
OkHttp3Utils.java
...ain/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
+5
-0
DeployController.java
.../ai/qiwu/com/tts_service/controller/DeployController.java
+4
-7
TTSController.java
...ava/ai/qiwu/com/tts_service/controller/TTSController.java
+0
-0
GeneralMP3Data.java
...ain/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
+2
-0
TTService.java
.../main/java/ai/qiwu/com/tts_service/service/TTService.java
+7
-20
TTServiceEdition2.java
...va/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
+4
-1
No files found.
.idea/workspace.xml
View file @
7f085a36
This diff is collapsed.
Click to expand it.
tts_service/src/main/java/ai/qiwu/com/tts_service/common/ApachHttpUtils.java
View file @
7f085a36
...
@@ -515,11 +515,11 @@ public class ApachHttpUtils {
...
@@ -515,11 +515,11 @@ public class ApachHttpUtils {
if
(
status
==
200
)
{
if
(
status
==
200
)
{
HttpEntity
httpEntity
=
response
.
getEntity
();
HttpEntity
httpEntity
=
response
.
getEntity
();
if
(
httpEntity
!=
null
){
if
(
httpEntity
!=
null
){
byte
[]
bytes
=
EntityUtils
.
toByteArray
(
httpEntity
);
//
byte[] bytes = EntityUtils.toByteArray(httpEntity);
//
String result = EntityUtils.toString(httpEntity, "UTF-8");
String
result
=
EntityUtils
.
toString
(
httpEntity
,
"UTF-8"
);
EntityUtils
.
consume
(
httpEntity
);
//关闭资源
EntityUtils
.
consume
(
httpEntity
);
//关闭资源
//
return result;
return
result
;
return
String
.
valueOf
(
bytes
.
length
);
//
return String.valueOf(bytes.length);
}
}
}
}
}
}
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/common/OkHttp3Utils.java
View file @
7f085a36
...
@@ -84,9 +84,14 @@ public class OkHttp3Utils {
...
@@ -84,9 +84,14 @@ public class OkHttp3Utils {
paramsIterator
.
forEachRemaining
(
e
->
urlBuild
.
addQueryParameter
(
e
.
getKey
(),
e
.
getValue
()));
paramsIterator
.
forEachRemaining
(
e
->
urlBuild
.
addQueryParameter
(
e
.
getKey
(),
e
.
getValue
()));
builder
.
url
(
urlBuild
.
build
()).
headers
(
headerBuilder
.
build
());
builder
.
url
(
urlBuild
.
build
()).
headers
(
headerBuilder
.
build
());
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 String.valueOf(body.bytes().length);
return
body
.
string
();
return
body
.
string
();
}
catch
(
Exception
e
)
{
log
.
error
(
"OKHTTP doGet error:"
+
e
);
return
null
;
}
}
}
}
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/controller/DeployController.java
View file @
7f085a36
...
@@ -154,7 +154,7 @@ public class DeployController {
...
@@ -154,7 +154,7 @@ public class DeployController {
log
.
error
(
"文件为空"
);
log
.
error
(
"文件为空"
);
return
ServerResponse
.
createByErrorEnum
(
ResponseCode
.
DATA_IS_WRONG
);
return
ServerResponse
.
createByErrorEnum
(
ResponseCode
.
DATA_IS_WRONG
);
}
}
if
(
type
.
equals
(
"default"
))
{
if
(
"default"
.
equals
(
type
))
{
if
(
StringUtils
.
isAnyBlank
(
type
,
auth
)
||
groupId
==
null
)
{
if
(
StringUtils
.
isAnyBlank
(
type
,
auth
)
||
groupId
==
null
)
{
log
.
error
(
"type:{}, auth:{}, groupId:{}"
,
type
,
auth
,
groupId
);
log
.
error
(
"type:{}, auth:{}, groupId:{}"
,
type
,
auth
,
groupId
);
return
ServerResponse
.
createByErrorEnum
(
ResponseCode
.
DATA_IS_WRONG
);
return
ServerResponse
.
createByErrorEnum
(
ResponseCode
.
DATA_IS_WRONG
);
...
@@ -181,8 +181,8 @@ public class DeployController {
...
@@ -181,8 +181,8 @@ public class DeployController {
result
=
ApachHttpUtils
.
get
(
url
,
headers
,
null
);
result
=
ApachHttpUtils
.
get
(
url
,
headers
,
null
);
JSONObject
resultJSONObject
=
JSON
.
parseObject
(
result
);
JSONObject
resultJSONObject
=
JSON
.
parseObject
(
result
);
if
(
ResponseCode
.
SUCCESS
.
getCode
().
equals
(
resultJSONObject
.
getIntValue
(
"code"
)))
{
if
(
ResponseCode
.
SUCCESS
.
getCode
().
equals
(
resultJSONObject
.
getIntValue
(
"code"
)))
{
String
path
=
""
;
String
path
;
if
(
botAccount
.
equals
(
""
))
{
if
(
""
.
equals
(
botAccount
))
{
path
=
"/game_editor_tmp/background/"
;
path
=
"/game_editor_tmp/background/"
;
}
else
{
}
else
{
path
=
"/game_editor_tmp"
+
File
.
separator
+
botAccount
+
"/background/"
;
path
=
"/game_editor_tmp"
+
File
.
separator
+
botAccount
+
"/background/"
;
...
@@ -209,14 +209,11 @@ public class DeployController {
...
@@ -209,14 +209,11 @@ public class DeployController {
switch
(
sampleRate
)
{
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
8000
:
sampleRate
=
8000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
47250
:
sampleRate
=
47250
;
break
;
case
48000
:
sampleRate
=
48000
;
break
;
case
48000
:
sampleRate
=
48000
;
break
;
case
50000
:
sampleRate
=
50000
;
break
;
case
88200
:
sampleRate
=
88200
;
break
;
case
96000
:
sampleRate
=
96000
;
break
;
default
:
sampleRate
=
44100
;
default
:
sampleRate
=
44100
;
}
}
if
(!
TTSUtils
.
changeAudioConfig
(
sampleRate
,
bitRate
,
Initialize
.
AUDIO_DIR
+
path
))
{
if
(!
TTSUtils
.
changeAudioConfig
(
sampleRate
,
bitRate
,
Initialize
.
AUDIO_DIR
+
path
))
{
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/controller/TTSController.java
View file @
7f085a36
This diff is collapsed.
Click to expand it.
tts_service/src/main/java/ai/qiwu/com/tts_service/pojo/GeneralMP3Data.java
View file @
7f085a36
...
@@ -28,6 +28,8 @@ public class GeneralMP3Data {
...
@@ -28,6 +28,8 @@ public class GeneralMP3Data {
private
String
npcName
;
private
String
npcName
;
private
String
tmpName
;
// 用于试听生成的临时mp3文件名
private
String
tmpName
;
// 用于试听生成的临时mp3文件名
// private String mode;
public
GeneralMP3Data
(
String
server
,
String
text
,
String
person
,
String
tone
,
String
botname
,
public
GeneralMP3Data
(
String
server
,
String
text
,
String
person
,
String
tone
,
String
botname
,
Boolean
cache
,
Double
volume
,
Double
speed
,
Double
pitch
)
{
Boolean
cache
,
Double
volume
,
Double
speed
,
Double
pitch
)
{
this
.
server
=
server
;
this
.
server
=
server
;
...
...
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
View file @
7f085a36
...
@@ -1547,6 +1547,7 @@ public class TTService {
...
@@ -1547,6 +1547,7 @@ public class TTService {
switch
(
sampleRate
)
{
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
8000
:
sampleRate
=
8000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
...
@@ -1607,6 +1608,7 @@ public class TTService {
...
@@ -1607,6 +1608,7 @@ public class TTService {
switch
(
sampleRate
)
{
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
8000
:
sampleRate
=
8000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
...
@@ -1935,15 +1937,12 @@ public class TTService {
...
@@ -1935,15 +1937,12 @@ public class TTService {
}
}
switch
(
sampleRate
)
{
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
8000
:
sampleRate
=
8000
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
47250
:
sampleRate
=
47250
;
break
;
case
48000
:
sampleRate
=
48000
;
break
;
case
48000
:
sampleRate
=
48000
;
break
;
case
50000
:
sampleRate
=
50000
;
break
;
case
88200
:
sampleRate
=
88200
;
break
;
case
96000
:
sampleRate
=
96000
;
break
;
default
:
sampleRate
=
44100
;
default
:
sampleRate
=
44100
;
}
}
...
@@ -2681,21 +2680,9 @@ public class TTService {
...
@@ -2681,21 +2680,9 @@ public class TTService {
}
}
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
Pattern
pattern
=
Pattern
.
compile
(
"1000[167]|1001[012]"
);
// String command = "soxi /home/yf01/下载/audioCut/1.mp3";
List
<
String
>
list
=
new
ArrayList
<>();
// String response = CallPython.soxiGetAudioConfig(command);
list
.
add
(
"10001"
);
String
response
=
"Input File : '/home/yf01/下载/audioCut/1.mp3'Channels : 1Sample Rate : 16000Precision : 16-bitDuration : 00:00:01.12 = 17856 samples ~ 83.7 CDDA sectorsFile Size : 4.46kBit Rate : 32.0kSample Encoding: MPEG audio (layer I, II or III)"
;
list
.
add
(
"10006"
);
System
.
out
.
println
(
response
);
list
.
add
(
"10007"
);
list
.
add
(
"10010"
);
list
.
add
(
"10011"
);
list
.
add
(
"10012"
);
list
.
add
(
"10013"
);
list
.
add
(
"10002"
);
for
(
String
item:
list
)
{
Matcher
matcher
=
pattern
.
matcher
(
item
);
while
(
matcher
.
find
())
{
System
.
out
.
println
(
matcher
.
group
(
0
));
}
}
}
}
}
}
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
View file @
7f085a36
...
@@ -365,7 +365,9 @@ public class TTServiceEdition2 {
...
@@ -365,7 +365,9 @@ public class TTServiceEdition2 {
if
(!
TTSUtils
.
doesFileExist
(
path
))
{
if
(!
TTSUtils
.
doesFileExist
(
path
))
{
ResponseCodeWithData
response1
=
generalMP3
(
moodUrl
,
data
,
path
,
"GET"
,
true
);
ResponseCodeWithData
response1
=
generalMP3
(
moodUrl
,
data
,
path
,
"GET"
,
true
);
if
(
response1
==
null
)
response1
=
new
ResponseCodeWithData
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
,
"tts_ls:generalMP3 return null"
);
if
(
response1
==
null
)
response1
=
new
ResponseCodeWithData
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
,
"tts_ls:generalMP3 return null"
);
// buildTTSTime(data.getText(), data.getPerson(), data.getText().length(), System.currentTimeMillis()-start);
// if (response1.getCode() == 200) {
// buildTTSTime(data.getText(), data.getPerson(), data.getText().length(), System.currentTimeMillis()-start);
// }
return
response1
;
return
response1
;
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -483,6 +485,7 @@ public class TTServiceEdition2 {
...
@@ -483,6 +485,7 @@ public class TTServiceEdition2 {
private
ResponseCodeWithData
requestTemplate
(
String
url
,
GeneralMP3Data
data
,
String
filePath
,
boolean
getOnline
)
{
private
ResponseCodeWithData
requestTemplate
(
String
url
,
GeneralMP3Data
data
,
String
filePath
,
boolean
getOnline
)
{
ResponseCodeWithData
res
;
ResponseCodeWithData
res
;
// data.setMode("test");
int
status
=
ApachHttpUtils
.
audioPost
(
url
,
JSON
.
toJSONString
(
data
),
filePath
);
int
status
=
ApachHttpUtils
.
audioPost
(
url
,
JSON
.
toJSONString
(
data
),
filePath
);
if
(
status
==
0
)
res
=
new
ResponseCodeWithData
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
,
"请求出错"
);
if
(
status
==
0
)
res
=
new
ResponseCodeWithData
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
,
"请求出错"
);
else
if
(
status
==
HttpServletResponse
.
SC_NOT_FOUND
&&
Initialize
.
OFFLINE_SERVER
.
equals
(
url
))
{
else
if
(
status
==
HttpServletResponse
.
SC_NOT_FOUND
&&
Initialize
.
OFFLINE_SERVER
.
equals
(
url
))
{
...
...
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