Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
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
项目统一框架
amos-boot-biz
Commits
949022bd
Commit
949022bd
authored
Dec 10, 2021
by
helinlin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
对接语音数据
parent
dd4a552c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
8 deletions
+10
-8
RealTimeStream2Text.java
...jcs/biz/audioToText/streamToText/RealTimeStream2Text.java
+2
-2
AppSpeechTranscriber.java
...in/java/com/yeejoin/amos/speech/AppSpeechTranscriber.java
+8
-6
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-jcs-biz/src/main/java/com/yeejoin/amos/boot/module/jcs/biz/audioToText/streamToText/RealTimeStream2Text.java
View file @
949022bd
...
...
@@ -64,8 +64,8 @@ public class RealTimeStream2Text {
Thread
thread1
=
new
Thread
(()
->
{
new
AppSpeechTranscriber
(
new
RealTimeSpeechTranscriberListener
(
myNumber
,
myNumber
,
emqKeeper
,
audioRecords
,
audioKeyWord
)
,
serverSocket1
,
localIpAddress
)
new
RealTimeSpeechTranscriberListener
(
myNumber
,
myNumber
,
emqKeeper
,
audioRecords
,
audioKeyWord
)
,
serverSocket1
,
localIpAddress
)
.
process
();
},
"我的语音流"
);
//呼入的语音流
...
...
amos-boot-utils/amos-boot-utils-speech/src/main/java/com/yeejoin/amos/speech/AppSpeechTranscriber.java
View file @
949022bd
...
...
@@ -9,7 +9,6 @@ import org.slf4j.LoggerFactory;
import
java.net.DatagramPacket
;
import
java.net.DatagramSocket
;
import
java.net.InetAddress
;
import
java.util.Arrays
;
import
java.util.Timer
;
import
java.util.TimerTask
;
...
...
@@ -29,6 +28,7 @@ public class AppSpeechTranscriber {
private
final
Timer
serverSocketTimeoutTimer
;
private
final
TimerTask
timerTask
;
private
final
String
localIpAddress
;
private
int
idleTime
=
0
;
public
AppSpeechTranscriber
(
SpeechTranscriberListener
listener
,
DatagramSocket
serverSocket
,
String
localIpAddress
)
{
this
.
localIpAddress
=
localIpAddress
;
...
...
@@ -39,11 +39,14 @@ public class AppSpeechTranscriber {
timerTask
=
new
TimerTask
()
{
@Override
public
void
run
()
{
logger
.
warn
(
"serverSocket,port:"
+
serverSocket
.
getLocalPort
()
+
" 等待60s无数据回复即将自动关闭!"
);
closeServerSocket
();
idleTime
++;
if
(
idleTime
>
60
)
{
logger
.
warn
(
"serverSocket,port:"
+
serverSocket
.
getLocalPort
()
+
" 等待60s无数据回复即将自动关闭!"
);
closeServerSocket
();
}
}
};
serverSocketTimeoutTimer
.
schedule
(
timerTask
,
1000
*
6
0
);
serverSocketTimeoutTimer
.
schedule
(
timerTask
,
0
,
100
0
);
}
/**
...
...
@@ -66,11 +69,10 @@ public class AppSpeechTranscriber {
setParam
(
transcriber
);
transcriber
.
start
();
}
serverSocketTimeoutTimer
.
cancel
()
;
idleTime
=
0
;
logger
.
warn
(
"收到数据包:"
+
b
.
length
);
//去掉前12个字节的rtp包头,后面的332字节为语音数据
transcriber
.
send
(
Arrays
.
copyOfRange
(
b
,
12
,
b
.
length
));
serverSocketTimeoutTimer
.
schedule
(
timerTask
,
1000
*
60
);
}
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
());
...
...
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