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
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
25 additions
and
31 deletions
+25
-31
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
+3
-0
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 {
if
(
status
==
200
)
{
HttpEntity
httpEntity
=
response
.
getEntity
();
if
(
httpEntity
!=
null
){
byte
[]
bytes
=
EntityUtils
.
toByteArray
(
httpEntity
);
//
String result = EntityUtils.toString(httpEntity, "UTF-8");
//
byte[] bytes = EntityUtils.toByteArray(httpEntity);
String
result
=
EntityUtils
.
toString
(
httpEntity
,
"UTF-8"
);
EntityUtils
.
consume
(
httpEntity
);
//关闭资源
//
return result;
return
String
.
valueOf
(
bytes
.
length
);
return
result
;
//
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 {
paramsIterator
.
forEachRemaining
(
e
->
urlBuild
.
addQueryParameter
(
e
.
getKey
(),
e
.
getValue
()));
builder
.
url
(
urlBuild
.
build
()).
headers
(
headerBuilder
.
build
());
Response
response
=
client
.
newCall
(
builder
.
build
()).
execute
();
try
(
ResponseBody
body
=
response
.
body
()){
// return String.valueOf(body.bytes().length);
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 {
log
.
error
(
"文件为空"
);
return
ServerResponse
.
createByErrorEnum
(
ResponseCode
.
DATA_IS_WRONG
);
}
if
(
type
.
equals
(
"default"
))
{
if
(
"default"
.
equals
(
type
))
{
if
(
StringUtils
.
isAnyBlank
(
type
,
auth
)
||
groupId
==
null
)
{
log
.
error
(
"type:{}, auth:{}, groupId:{}"
,
type
,
auth
,
groupId
);
return
ServerResponse
.
createByErrorEnum
(
ResponseCode
.
DATA_IS_WRONG
);
...
...
@@ -181,8 +181,8 @@ public class DeployController {
result
=
ApachHttpUtils
.
get
(
url
,
headers
,
null
);
JSONObject
resultJSONObject
=
JSON
.
parseObject
(
result
);
if
(
ResponseCode
.
SUCCESS
.
getCode
().
equals
(
resultJSONObject
.
getIntValue
(
"code"
)))
{
String
path
=
""
;
if
(
botAccount
.
equals
(
""
))
{
String
path
;
if
(
""
.
equals
(
botAccount
))
{
path
=
"/game_editor_tmp/background/"
;
}
else
{
path
=
"/game_editor_tmp"
+
File
.
separator
+
botAccount
+
"/background/"
;
...
...
@@ -209,14 +209,11 @@ public class DeployController {
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
47250
:
sampleRate
=
47250
;
break
;
case
48000
:
sampleRate
=
48000
;
break
;
case
50000
:
sampleRate
=
50000
;
break
;
case
88200
:
sampleRate
=
88200
;
break
;
case
96000
:
sampleRate
=
96000
;
break
;
default
:
sampleRate
=
44100
;
}
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 {
private
String
npcName
;
private
String
tmpName
;
// 用于试听生成的临时mp3文件名
// private String mode;
public
GeneralMP3Data
(
String
server
,
String
text
,
String
person
,
String
tone
,
String
botname
,
Boolean
cache
,
Double
volume
,
Double
speed
,
Double
pitch
)
{
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 {
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
...
...
@@ -1607,6 +1608,7 @@ public class TTService {
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
...
...
@@ -1935,15 +1937,12 @@ public class TTService {
}
switch
(
sampleRate
)
{
case
8000
:
sampleRate
=
8000
;
break
;
case
16000
:
sampleRate
=
16000
;
break
;
case
11025
:
sampleRate
=
11025
;
break
;
case
22050
:
sampleRate
=
22050
;
break
;
case
32000
:
sampleRate
=
32000
;
break
;
case
44100
:
sampleRate
=
44100
;
break
;
case
47250
:
sampleRate
=
47250
;
break
;
case
48000
:
sampleRate
=
48000
;
break
;
case
50000
:
sampleRate
=
50000
;
break
;
case
88200
:
sampleRate
=
88200
;
break
;
case
96000
:
sampleRate
=
96000
;
break
;
default
:
sampleRate
=
44100
;
}
...
...
@@ -2681,21 +2680,9 @@ public class TTService {
}
public
static
void
main
(
String
[]
args
)
throws
UnsupportedEncodingException
{
Pattern
pattern
=
Pattern
.
compile
(
"1000[167]|1001[012]"
);
List
<
String
>
list
=
new
ArrayList
<>();
list
.
add
(
"10001"
);
list
.
add
(
"10006"
);
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
));
}
}
// String command = "soxi /home/yf01/下载/audioCut/1.mp3";
// String response = CallPython.soxiGetAudioConfig(command);
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)"
;
System
.
out
.
println
(
response
);
}
}
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTServiceEdition2.java
View file @
7f085a36
...
...
@@ -365,7 +365,9 @@ public class TTServiceEdition2 {
if
(!
TTSUtils
.
doesFileExist
(
path
))
{
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.getCode() == 200) {
// buildTTSTime(data.getText(), data.getPerson(), data.getText().length(), System.currentTimeMillis()-start);
// }
return
response1
;
}
}
catch
(
Exception
e
)
{
...
...
@@ -483,6 +485,7 @@ public class TTServiceEdition2 {
private
ResponseCodeWithData
requestTemplate
(
String
url
,
GeneralMP3Data
data
,
String
filePath
,
boolean
getOnline
)
{
ResponseCodeWithData
res
;
// data.setMode("test");
int
status
=
ApachHttpUtils
.
audioPost
(
url
,
JSON
.
toJSONString
(
data
),
filePath
);
if
(
status
==
0
)
res
=
new
ResponseCodeWithData
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
,
"请求出错"
);
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