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
ecb902b7
Commit
ecb902b7
authored
Jun 17, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改音频识别结果
parent
1620e1e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
18 deletions
+26
-18
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
.../java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
+9
-6
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
...in/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
+13
-8
robot-trans-manager/src/test/java/httpclient/system.http
robot-trans-manager/src/test/java/httpclient/system.http
+4
-4
No files found.
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
View file @
ecb902b7
...
...
@@ -97,15 +97,18 @@ public class ApiSendMsgController {
String
jsonStr
=
""
;
try
{
if
(
file
==
null
||
file
.
getSize
()
==
0L
)
throw
new
AppException
(
"文件为空!"
);
if
(!
"pcm"
.
equalsIgnoreCase
(
FileUtil
.
getSuffix
(
file
.
getOriginalFilename
()))&&
/*
if (!"pcm".equalsIgnoreCase(FileUtil.getSuffix(file.getOriginalFilename()))&&
!"mp3".equalsIgnoreCase(FileUtil.getSuffix(file.getOriginalFilename())))
throw
new
AppException
(
"只支持pcm或mp3文件!"
);
throw new AppException("只支持pcm或mp3文件!");
*/
//if (file.getOriginalFilename())
String
filePath
=
uploadService
.
saveFileUpload
(
file
,
prePath
,
null
);
filePath
=
uploadService
.
getFilePath
(
filePath
);
//
String filePath = uploadService.saveFileUpload(file, prePath, null);
//
filePath = uploadService.getFilePath(filePath);
log
.
info
(
"filePath==>"
+
filePath
);
IatModelMulUtil
iatModelMulUtil
=
new
IatModelMulUtil
(
filePath
,
appid
);
//log.info("filePath==>" + filePath);
byte
[]
bytes
=
file
.
getBytes
();
IatModelMulUtil
iatModelMulUtil
=
new
IatModelMulUtil
(
bytes
,
appid
);
String
authUrl
=
IatModelMulUtil
.
getAuthUrl
(
hostUrl
,
apiKey
,
apiSecret
);
//log.info("authUrl==>" + authUrl);
...
...
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
View file @
ecb902b7
...
...
@@ -53,9 +53,12 @@ public class IatModelMulUtil extends WebSocketListener {
public
String
appid
;
private
byte
[]
bytes
;
public
IatModelMulUtil
(
String
file
,
String
appid
)
{
this
.
file
=
file
;
public
IatModelMulUtil
(
byte
[]
bytes
,
String
appid
)
{
// this.file = file;
this
.
bytes
=
bytes
;
this
.
appid
=
appid
;
}
...
...
@@ -69,13 +72,15 @@ public class IatModelMulUtil extends WebSocketListener {
int
intervel
=
40
;
int
status
=
0
;
// 音频的状态
int
seq
=
0
;
//数据序号
try
(
FileInputStream
fs
=
new
FileInputStream
(
file
))
{
byte
[]
buffer
=
new
byte
[
frameSize
];
// try (FileInputStream fs = new FileInputStream(file)) {
try
{
// byte[] buffer = new byte[frameSize];
// 发送音频
end:
while
(
true
)
{
seq
++;
// 每次循环更新下seq
int
len
=
fs
.
read
(
buffer
);
// int len = fs.read(buffer);
int
len
=
bytes
.
length
;
if
(
len
==
-
1
)
{
status
=
StatusLastFrame
;
//文件读完,改变status 为 2
}
...
...
@@ -111,7 +116,7 @@ public class IatModelMulUtil extends WebSocketListener {
audio
.
setBitDepth
(
16
);
audio
.
setSeq
(
seq
);
audio
.
setStatus
(
status
);
audio
.
setAudio
(
Base64
.
getEncoder
().
encodeToString
(
Arrays
.
copyOf
(
b
uffer
,
len
)));
audio
.
setAudio
(
Base64
.
getEncoder
().
encodeToString
(
Arrays
.
copyOf
(
b
ytes
,
len
)));
payload
.
setAudio
(
audio
);
audioRoot
.
setPayload
(
payload
);
...
...
@@ -148,7 +153,7 @@ public class IatModelMulUtil extends WebSocketListener {
" }\n" +
" }\n" +
"}";*/
//
log.info("first json==>" + json);
log
.
info
(
"first json==>"
+
json
);
webSocket
.
send
(
json
);
status
=
StatusContinueFrame
;
// 发送完第一帧改变status 为 1
break
;
...
...
@@ -167,7 +172,7 @@ public class IatModelMulUtil extends WebSocketListener {
audio
.
setBitDepth
(
16
);
audio
.
setSeq
(
seq
);
audio
.
setStatus
(
status
);
audio
.
setAudio
(
Base64
.
getEncoder
().
encodeToString
(
Arrays
.
copyOf
(
b
uffer
,
len
)));
audio
.
setAudio
(
Base64
.
getEncoder
().
encodeToString
(
Arrays
.
copyOf
(
b
ytes
,
len
)));
payload
.
setAudio
(
audio
);
audioRoot
.
setPayload
(
payload
);
...
...
robot-trans-manager/src/test/java/httpclient/system.http
View file @
ecb902b7
...
...
@@ -39,9 +39,9 @@ POST {{baseUrl}}/audio/upload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="
test.mp3
"
Content-Disposition: form-data; name="file"; filename="
new.opus
"
< ./
test.mp3
< ./
new.opus
--WebAppBoundary--
###上传音频文件1
...
...
@@ -49,9 +49,9 @@ POST {{baseUrl}}/audio/upload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="test.pcm"
Content-Disposition: form-data; name="file"; filename="test
4
.pcm"
< ./test
1
.pcm
< ./test
4
.pcm
--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