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
c740db49
Commit
c740db49
authored
Jun 16, 2025
by
赵啸非
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加音频识别
parent
f8ab5faa
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
327 additions
and
39 deletions
+327
-39
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
.../java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
+20
-37
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulMain.java
...in/java/com/mortals/xhx/common/utils/IatModelMulMain.java
+2
-2
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
...in/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
+294
-0
robot-trans-manager/src/test/java/httpclient/system.http
robot-trans-manager/src/test/java/httpclient/system.http
+11
-0
robot-trans-manager/src/test/java/httpclient/test.pcm
robot-trans-manager/src/test/java/httpclient/test.pcm
+0
-0
No files found.
robot-trans-manager/src/main/java/com/mortals/xhx/busiz/web/ApiSendMsgController.java
View file @
c740db49
...
...
@@ -7,7 +7,11 @@ import com.mortals.framework.service.ILogService;
import
com.mortals.framework.service.impl.FileLogServiceImpl
;
import
com.mortals.xhx.base.system.upload.service.UploadService
;
import
com.mortals.xhx.common.utils.IatModelMulMain
;
import
com.mortals.xhx.common.utils.IatModelMulUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
okhttp3.OkHttpClient
;
import
okhttp3.Request
;
import
okhttp3.WebSocket
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
@@ -49,39 +53,11 @@ public class ApiSendMsgController {
@GetMapping
(
value
=
"/events/create"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
public
Flux
<
String
>
streamEventsCreate
()
{
/* return Flux.push(sink -> {
new Thread(() -> {
try {
for (int i = 1; i <= 1; i++) {
sink.next("Message " + i);
Thread.sleep(1000);
}
sink.complete();
} catch (InterruptedException e) {
sink.error(e);
}
}).start();
});*/
/* return Flux.create(sink -> {
ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
executor.scheduleAtFixedRate(() -> {
sink.next("Message " + System.currentTimeMillis());
}, 0, 1, TimeUnit.SECONDS);
});*/
return
Flux
.
create
(
sink
->
{
for
(
int
i
=
1
;
i
<=
10
;
i
++)
{
new
Thread
(()
->
{
// 需要异步执行,否则会阻塞
sink
.
next
(
"Message "
);
// 每秒发送一条数据
}).
start
();
try
{
...
...
@@ -92,9 +68,6 @@ public class ApiSendMsgController {
}
sink
.
complete
();
// 结束流
});
//return null;
}
@GetMapping
(
"/emitter"
)
...
...
@@ -113,17 +86,27 @@ public class ApiSendMsgController {
return
emitter
;
}
@RequestMapping
(
value
=
"upload"
)
public
String
doFileUpload
(
MultipartFile
file
,
@RequestParam
(
value
=
"prePath"
,
defaultValue
=
""
)
String
prePath
)
{
@RequestMapping
(
value
=
"upload"
,
produces
=
MediaType
.
TEXT_EVENT_STREAM_VALUE
)
@UnAuth
public
SseEmitter
doFileUpload
(
MultipartFile
file
,
@RequestParam
(
value
=
"prePath"
,
defaultValue
=
""
)
String
prePath
)
{
Map
<
String
,
Object
>
model
=
new
HashMap
<>();
String
jsonStr
=
""
;
SseEmitter
emitter
=
new
SseEmitter
(
30000L
);
try
{
String
filePath
=
uploadService
.
saveFileUpload
(
file
,
prePath
,
null
);
//将音频文件传给ai大模型
filePath
=
uploadService
.
getFilePath
(
filePath
);
// IatModelMulMain.getAuthUrl()
IatModelMulUtil
iatModelMulUtil
=
new
IatModelMulUtil
(
filePath
,
appid
,
emitter
);
String
authUrl
=
iatModelMulUtil
.
getAuthUrl
(
hostUrl
,
apiKey
,
apiSecret
);
//log.info("authUrl==>" + authUrl);
OkHttpClient
client
=
new
OkHttpClient
.
Builder
().
build
();
String
url
=
authUrl
.
toString
().
replace
(
"http://"
,
"ws://"
).
replace
(
"https://"
,
"wss://"
);
Request
request
=
new
Request
.
Builder
().
url
(
url
).
build
();
WebSocket
webSocket
=
client
.
newWebSocket
(
request
,
iatModelMulUtil
);
// model.put("url", filePath);
model
.
put
(
"fileName"
,
file
.
getOriginalFilename
());
...
...
@@ -140,7 +123,7 @@ public class ApiSendMsgController {
model.put(KEY_RESULT_MSG, "文件上传失败");*/
jsonStr
=
JSONObject
.
toJSONString
(
model
);
}
return
jsonSt
r
;
return
emitte
r
;
}
}
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulMain.java
View file @
c740db49
...
...
@@ -114,7 +114,7 @@ public class IatModelMulMain extends WebSocketListener {
"}"
;
webSocket
.
send
(
json
);
// System.err.println(json);
System
.
out
.
println
(
"中间帧音频发送中..."
+
seq
);
//
System.out.println("中间帧音频发送中..."+seq);
break
;
case
StatusLastFrame:
// 最后一帧音频status = 2 ,标志音频发送结束
json
=
"{\n"
+
...
...
@@ -155,7 +155,7 @@ public class IatModelMulMain extends WebSocketListener {
@Override
public
void
onMessage
(
WebSocket
webSocket
,
String
text
)
{
super
.
onMessage
(
webSocket
,
text
);
System
.
out
.
println
(
text
);
//
System.out.println(text);
JsonParse
jsonParse
=
gson
.
fromJson
(
text
,
JsonParse
.
class
);
if
(
jsonParse
!=
null
)
{
if
(
jsonParse
.
header
.
code
!=
0
)
{
...
...
robot-trans-manager/src/main/java/com/mortals/xhx/common/utils/IatModelMulUtil.java
0 → 100644
View file @
c740db49
This diff is collapsed.
Click to expand it.
robot-trans-manager/src/test/java/httpclient/system.http
View file @
c740db49
...
...
@@ -33,6 +33,17 @@ Content-Disposition: form-data; name="file"; filename="file.zip"
< ./file.zip
--WebAppBoundary--
###上传音频文件
POST {{baseUrl}}/audio/upload
Content-Type: multipart/form-data; boundary=WebAppBoundary
--WebAppBoundary
Content-Disposition: form-data; name="file"; filename="test.pcm"
< ./test.pcm
--WebAppBoundary--
###测试链接数据库
POST {{baseUrl}}/m/db/connect
Content-Type: application/json
...
...
robot-trans-manager/src/test/java/httpclient/test.pcm
0 → 100644
View file @
c740db49
File added
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