Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
robot-trans-platform
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
赵啸非
robot-trans-platform
Commits
16a414d7
Commit
16a414d7
authored
Jun 16, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加音频识别
parent
4089b544
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
13 deletions
+24
-13
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
.../java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
+18
-9
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
...in/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
+5
-3
robot-trans-manager/src/test/java/httpclient/http-client.env.json
...ans-manager/src/test/java/httpclient/http-client.env.json
+1
-1
No files found.
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
View file @
16a414d7
...
@@ -96,9 +96,10 @@ public class ApiSendMsgController {
...
@@ -96,9 +96,10 @@ public class ApiSendMsgController {
SseEmitter
emitter
=
new
SseEmitter
(
10
*
60
*
1000L
);
SseEmitter
emitter
=
new
SseEmitter
(
10
*
60
*
1000L
);
try
{
try
{
if
(
file
==
null
||
file
.
getSize
()==
0L
)
throw
new
AppException
(
"文件为空!"
);
if
(
file
==
null
||
file
.
getSize
()
==
0L
)
throw
new
AppException
(
"文件为空!"
);
if
(!
"pcm"
.
equalsIgnoreCase
(
FileUtil
.
getSuffix
(
file
.
getOriginalFilename
())))
throw
new
AppException
(
"只支持pcm文件!"
);
if
(!
"pcm"
.
equalsIgnoreCase
(
FileUtil
.
getSuffix
(
file
.
getOriginalFilename
())))
throw
new
AppException
(
"只支持pcm文件!"
);
//if (file.getOriginalFilename())
//if (file.getOriginalFilename())
...
@@ -108,31 +109,39 @@ public class ApiSendMsgController {
...
@@ -108,31 +109,39 @@ public class ApiSendMsgController {
log
.
info
(
"filePath==>"
+
filePath
);
log
.
info
(
"filePath==>"
+
filePath
);
IatModelMulUtil
iatModelMulUtil
=
new
IatModelMulUtil
(
filePath
,
appid
,
emitter
);
//
IatModelMulUtil iatModelMulUtil = new IatModelMulUtil(filePath, appid, emitter);
String
authUrl
=
iatModelMulUtil
.
getAuthUrl
(
hostUrl
,
apiKey
,
apiSecret
);
IatModelMulUtil
.
file
=
filePath
;
IatModelMulUtil
.
emitter
=
emitter
;
IatModelMulUtil
.
appid
=
appid
;
String
authUrl
=
IatModelMulUtil
.
getAuthUrl
(
hostUrl
,
apiKey
,
apiSecret
);
//log.info("authUrl==>" + authUrl);
//log.info("authUrl==>" + authUrl);
OkHttpClient
client
=
new
OkHttpClient
.
Builder
().
build
();
OkHttpClient
client
=
new
OkHttpClient
.
Builder
().
build
();
String
url
=
authUrl
.
toString
().
replace
(
"http://"
,
"ws://"
).
replace
(
"https://"
,
"wss://"
);
String
url
=
authUrl
.
toString
().
replace
(
"http://"
,
"ws://"
).
replace
(
"https://"
,
"wss://"
);
Request
request
=
new
Request
.
Builder
().
url
(
url
).
build
();
Request
request
=
new
Request
.
Builder
().
url
(
url
).
build
();
WebSocket
webSocket
=
client
.
newWebSocket
(
request
,
iatModelMulUtil
);
WebSocket
webSocket
=
client
.
newWebSocket
(
request
,
new
IatModelMulUtil
()
);
// model.put("url", filePath);
// model.put("url", filePath);
model
.
put
(
"fileName"
,
file
.
getOriginalFilename
());
model
.
put
(
"fileName"
,
file
.
getOriginalFilename
());
// model.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
// model.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonStr
=
JSONObject
.
toJSONString
(
model
);
jsonStr
=
JSONObject
.
toJSONString
(
model
);
}
catch
(
AppException
e
)
{
}
catch
(
AppException
e
)
{
emitter
.
complete
();
/* log.debug(e);
/* log.debug(e);
model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
model.put(KEY_RESULT_MSG, e.getMessage());*/
model.put(KEY_RESULT_MSG, e.getMessage());*/
jsonStr
=
JSONObject
.
toJSONString
(
model
);
// jsonStr = JSONObject.toJSONString(model);
return
null
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
emitter
.
complete
();
return
null
;
/* model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
/* model.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
model.put(KEY_RESULT_MSG, "文件上传失败");*/
model.put(KEY_RESULT_MSG, "文件上传失败");*/
jsonStr
=
JSONObject
.
toJSONString
(
model
);
//
jsonStr = JSONObject.toJSONString(model);
}
}
return
emitter
;
return
emitter
;
}
}
...
...
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
View file @
16a414d7
...
@@ -40,17 +40,19 @@ public class IatModelMulUtil extends WebSocketListener {
...
@@ -40,17 +40,19 @@ public class IatModelMulUtil extends WebSocketListener {
private
static
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyy-MM-dd HH:mm:ss.SSS"
);
private
static
final
SimpleDateFormat
sdf
=
new
SimpleDateFormat
(
"yyy-MM-dd HH:mm:ss.SSS"
);
p
rivate
String
file
;
// 识别音频位置*/
p
ublic
static
String
file
;
// 识别音频位置*/
p
rivate
String
appid
;
p
ublic
static
String
appid
;
p
rivate
SseEmitter
emitter
;
p
ublic
static
SseEmitter
emitter
;
/*
public IatModelMulUtil(String file, String appid, SseEmitter emitter) {
public IatModelMulUtil(String file, String appid, SseEmitter emitter) {
this.file = file;
this.file = file;
this.appid = appid;
this.appid = appid;
this.emitter = emitter;
this.emitter = emitter;
}
}
*/
@Override
@Override
public
void
onOpen
(
WebSocket
webSocket
,
Response
response
)
{
public
void
onOpen
(
WebSocket
webSocket
,
Response
response
)
{
...
...
robot-trans-manager/src/test/java/httpclient/http-client.env.json
View file @
16a414d7
...
@@ -6,7 +6,7 @@
...
@@ -6,7 +6,7 @@
"baseUrl"
:
"http://127.0.0.1:18001/m"
"baseUrl"
:
"http://127.0.0.1:18001/m"
},
},
"test"
:
{
"test"
:
{
"baseUrl"
:
"http://192.168.0.
250:8082/m
"
"baseUrl"
:
"http://192.168.0.
98:18006
"
},
},
"prod"
:
{
"prod"
:
{
"baseUrl"
:
"http://robot.scsmile.cn"
"baseUrl"
:
"http://robot.scsmile.cn"
...
...
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