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
e2f66c93
Commit
e2f66c93
authored
Jul 03, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改音频识别结果
parent
9f18dc7a
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
397 additions
and
16 deletions
+397
-16
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
.../java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
+17
-12
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatATWSUtil.java
...c/main/java/com/mortals/xhx/common/utils/IatATWSUtil.java
+2
-2
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/WebIATWS.java
.../src/main/java/com/mortals/xhx/common/utils/WebIATWS.java
+376
-0
robot-trans-manager/src/test/java/httpclient/recording.pcm
robot-trans-manager/src/test/java/httpclient/recording.pcm
+0
-0
robot-trans-manager/src/test/java/httpclient/system.http
robot-trans-manager/src/test/java/httpclient/system.http
+2
-2
No files found.
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
View file @
e2f66c93
...
@@ -11,6 +11,7 @@ import com.mortals.xhx.base.system.upload.service.UploadService;
...
@@ -11,6 +11,7 @@ import com.mortals.xhx.base.system.upload.service.UploadService;
import
com.mortals.xhx.common.utils.IatATWSUtil
;
import
com.mortals.xhx.common.utils.IatATWSUtil
;
import
com.mortals.xhx.common.utils.IatModelMulMain
;
import
com.mortals.xhx.common.utils.IatModelMulMain
;
import
com.mortals.xhx.common.utils.IatModelMulUtil
;
import
com.mortals.xhx.common.utils.IatModelMulUtil
;
import
com.mortals.xhx.common.utils.WebIATWS
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.Request
;
...
@@ -99,31 +100,35 @@ public class ApiSendMsgController {
...
@@ -99,31 +100,35 @@ public class ApiSendMsgController {
String
jsonStr
=
""
;
String
jsonStr
=
""
;
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())))
if
(!
"pcm"
.
equalsIgnoreCase
(
FileUtil
.
getSuffix
(
file
.
getOriginalFilename
())))
// throw new AppException("只支持pcm!");
throw
new
AppException
(
"只支持pcm!"
);
// //if (file.getOriginalFilename())
//if (file.getOriginalFilename())
// String filePath = uploadService.saveFileUpload(file, prePath, null);
String
filePath
=
uploadService
.
saveFileUpload
(
file
,
prePath
,
null
);
// filePath = uploadService.getFilePath(filePath);
filePath
=
uploadService
.
getFilePath
(
filePath
);
//
// log.info("filePath==>" + filePath);
byte
[]
bytes
=
file
.
getBytes
();
log
.
info
(
"filePath==>"
+
filePath
);
WebIATWS
webIATWS
=
new
WebIATWS
(
filePath
);
String
authUrl
=
WebIATWS
.
getAuthUrl
(
hostUrl
,
apiKey
,
apiSecret
);
// byte[] bytes = file.getBytes();
// IatModelMulUtil iatModelMulUtil = new IatModelMulUtil(filePath, appid);
// IatModelMulUtil iatModelMulUtil = new IatModelMulUtil(filePath, appid);
// IatModelMulUtil iatModelMulUtil = new IatModelMulUtil(bytes, appid);
// IatModelMulUtil iatModelMulUtil = new IatModelMulUtil(bytes, appid);
IatATWSUtil
iatModelMulUtil
=
new
IatATWSUtil
(
bytes
,
appid
);
//
IatATWSUtil iatModelMulUtil = new IatATWSUtil(bytes, appid);
String
authUrl
=
IatATWSUtil
.
getAuthUrl
(
hostUrl
,
apiKey
,
apiSecret
);
//
String authUrl = IatATWSUtil.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
,
webIATWS
);
// 等待返回结果(阻塞直到收到完整数据或超时)
// 等待返回结果(阻塞直到收到完整数据或超时)
String
result
=
iatModelMulUtil
.
getResultFuture
().
get
(
60
,
TimeUnit
.
SECONDS
);
String
result
=
webIATWS
.
getResultFuture
().
get
(
60
,
TimeUnit
.
SECONDS
);
log
.
info
(
"识别结果:"
+
result
);
log
.
info
(
"识别结果:"
+
result
);
model
.
put
(
"result"
,
result
);
model
.
put
(
"result"
,
result
);
// model.put("url", filePath);
// model.put("url", filePath);
...
...
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatATWSUtil.java
View file @
e2f66c93
...
@@ -156,7 +156,7 @@ public class IatATWSUtil extends WebSocketListener {
...
@@ -156,7 +156,7 @@ public class IatATWSUtil extends WebSocketListener {
@Override
@Override
public
void
onMessage
(
WebSocket
webSocket
,
String
text
)
{
public
void
onMessage
(
WebSocket
webSocket
,
String
text
)
{
super
.
onMessage
(
webSocket
,
text
);
super
.
onMessage
(
webSocket
,
text
);
log
.
info
(
"onMessage==>"
+
text
);
//
log.info("onMessage==>" + text);
ResponseData
resp
=
gson
.
fromJson
(
text
,
ResponseData
.
class
);
ResponseData
resp
=
gson
.
fromJson
(
text
,
ResponseData
.
class
);
if
(
resp
!=
null
)
{
if
(
resp
!=
null
)
{
if
(
resp
.
getCode
()
!=
0
)
{
if
(
resp
.
getCode
()
!=
0
)
{
...
@@ -167,7 +167,7 @@ public class IatATWSUtil extends WebSocketListener {
...
@@ -167,7 +167,7 @@ public class IatATWSUtil extends WebSocketListener {
if
(
resp
.
getData
()
!=
null
)
{
if
(
resp
.
getData
()
!=
null
)
{
if
(
resp
.
getData
().
getResult
()
!=
null
)
{
if
(
resp
.
getData
().
getResult
()
!=
null
)
{
Text
te
=
resp
.
getData
().
getResult
().
getText
();
Text
te
=
resp
.
getData
().
getResult
().
getText
();
//
System.out.println(te.toString());
System
.
out
.
println
(
te
.
toString
());
try
{
try
{
decoder
.
decode
(
te
);
decoder
.
decode
(
te
);
// System.out.println("中间识别结果 ==》" + decoder.toString());
// System.out.println("中间识别结果 ==》" + decoder.toString());
...
...
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/WebIATWS.java
0 → 100644
View file @
e2f66c93
This diff is collapsed.
Click to expand it.
robot-trans-manager/src/test/java/httpclient/recording.pcm
View file @
e2f66c93
No preview for this file type
robot-trans-manager/src/test/java/httpclient/system.http
View file @
e2f66c93
...
@@ -40,9 +40,9 @@ POST {{baseUrl}}/audio/upload
...
@@ -40,9 +40,9 @@ POST {{baseUrl}}/audio/upload
Content-Type: multipart/form-data; boundary=WebAppBoundary
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="
test
.pcm"
Content-Disposition: form-data; name="file"; filename="
recording
.pcm"
< ./
test
.pcm
< ./
recording
.pcm
--WebAppBoundary--
--WebAppBoundary--
###测试链接数据库
###测试链接数据库
...
...
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