Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hublot
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Yoann HOUPERT
hublot
Commits
32ec84d7
Commit
32ec84d7
authored
Mar 29, 2018
by
Yoann HOUPERT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add generator wav
parent
28bc87bd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
154 additions
and
7 deletions
+154
-7
app.js
app.js
+2
-1
client/robot/robot.js
client/robot/robot.js
+6
-1
config.json
config.json
+15
-0
lib/proxy.js
lib/proxy.js
+14
-5
lib/resume.js
lib/resume.js
+117
-0
No files found.
app.js
View file @
32ec84d7
...
...
@@ -27,6 +27,7 @@ const loader = require('./lib/loader.js')('./client');
const
controllerFactory
=
require
(
'
./lib/controller.js
'
);
const
proxy
=
require
(
'
./lib/proxy.js
'
)(
config
.
proxy
);
const
resumeGenerator
=
require
(
'
./lib/resume.js
'
)(
config
.
offline
)
console
.
log
(
'
starting hublot...
'
);
...
...
@@ -43,7 +44,7 @@ loader.loadAll('controller', 'lib', 'robot')
console
.
log
(
'
App listening on port 3000
'
);
});
proxy
.
create
();
proxy
.
create
(
resumeGenerator
);
})
.
catch
(
err
=>
{
console
.
error
(
err
);
...
...
client/robot/robot.js
View file @
32ec84d7
...
...
@@ -111,11 +111,16 @@ robot = {
getUserStream
(
easyrtcid
)
{
robotController
.
getRemoteStream
(
easyrtcid
).
then
(
stream
=>
{
if
(
stream
!==
undefined
)
{
robot
.
participantsMediaRecorders
[
easyrtcid
]
=
robot
.
processAudio
(
stream
,
e
=>
robot
.
recordedParticipantsWS
[
easyrtcid
].
send
(
e
.
data
),
100
);
robot
.
participantsMediaRecorders
[
easyrtcid
]
=
robot
.
processAudio
(
stream
,
e
=>
robot
.
audioGenerator
(
easyrtcid
,
e
),
100
);
}
});
},
audioGenerator
(
easyrtcid
,
e
)
{
robot
.
recordedParticipantsWS
[
easyrtcid
].
send
(
e
.
data
);
},
recordParticipant
(
easyrtcid
)
{
robot
.
openSTTSocket
(
easyrtcid
);
robot
.
getUserStream
(
easyrtcid
);
...
...
config.json
View file @
32ec84d7
...
...
@@ -47,5 +47,20 @@
},
"kaldi"
:
"ws://hublot_kaldi-gstreamer_1:80/client/ws/speech?content-type=audio/x-matroska,+rate=(int)48000,+channels=(int)"
}
},
"offline"
:
{
"folder"
:
{
"audioRaw"
:
"audio_raw"
,
"audio"
:
"audio_wav"
,
"audioMerged"
:
"audio_merged"
},
"audio"
:{
"format"
:
"wav"
,
"bitrate"
:
"16k"
,
"channels"
:
1
,
"srate"
:
16000
},
"host"
:
"hublot_offline_1"
,
"port"
:
9999
}
}
lib/proxy.js
View file @
32ec84d7
...
...
@@ -54,14 +54,18 @@ module.exports = config => {
return
stompCapsule
;
}
function
kaldiWS
(
connectionToClient
)
{
function
kaldiWS
(
connectionToClient
,
resume
)
{
const
connectionToKaldi
=
new
WebSocket
(
config
.
services
.
kaldi
);
connectionToKaldi
.
on
(
'
open
'
,
()
=>
{
const
streamData
=
resume
.
generateStream
();
connectionToClient
.
on
(
'
message
'
,
message
=>
{
connectionToKaldi
.
send
(
message
,
{
binary
:
true
});
streamData
.
wstream
.
write
(
message
);
});
connectionToKaldi
.
on
(
'
message
'
,
message
=>
{
try
{
connectionToClient
.
send
(
message
);
...
...
@@ -72,7 +76,10 @@ module.exports = config => {
});
connectionToClient
.
on
(
'
close
'
,
()
=>
connectionToKaldi
.
close
());
connectionToKaldi
.
on
(
'
close
'
,
()
=>
connectionToClient
.
close
());
connectionToKaldi
.
on
(
'
close
'
,
()
=>
{
resume
.
endStream
(
streamData
)
connectionToClient
.
close
()
});
});
}
...
...
@@ -120,7 +127,7 @@ module.exports = config => {
}
}
else
{
console
.
error
(
'
Online reco: error trying to reach http://%s:%s/resources
'
,
config
.
services
.
reco
.
host
,
config
.
services
.
reco
.
port
);
config
.
services
.
reco
.
host
,
config
.
services
.
reco
.
port
);
}
connectionToClient
.
close
();
}
...
...
@@ -138,7 +145,9 @@ module.exports = config => {
}
return
{
create
:
()
=>
{
create
:
(
resume
)
=>
{
resume
.
createFolder
()
const
server
=
http
.
createServer
();
const
stompClient
=
createStompClient
();
...
...
@@ -150,7 +159,7 @@ module.exports = config => {
wssServer
.
on
(
'
connection
'
,
(
connectionToClient
,
req
)
=>
{
if
(
req
.
url
===
'
/kaldi
'
)
{
kaldiWS
(
connectionToClient
);
kaldiWS
(
connectionToClient
,
resume
);
return
;
}
if
(
req
.
url
===
'
/chat
'
)
{
...
...
lib/resume.js
0 → 100644
View file @
32ec84d7
/*
* Copyright (c) 2017 Linagora.
*
* This file is part of Hublot
* (see https://ci.linagora.com/linagora/lgs/labs/hublot).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const
fs
=
require
(
'
fs
'
);
const
uuidv1
=
require
(
'
uuid/v1
'
);
const
ffmpegInstaller
=
require
(
'
@ffmpeg-installer/ffmpeg
'
);
const
ffprobeInstaller
=
require
(
'
@ffprobe-installer/ffprobe
'
);
const
ffmpeg
=
require
(
'
fluent-ffmpeg
'
);
ffmpeg
.
setFfmpegPath
(
ffmpegInstaller
.
path
);
ffmpeg
.
setFfprobePath
(
ffprobeInstaller
.
path
);
module
.
exports
=
ffmpeg
;
module
.
exports
=
config
=>
{
let
timestamp
=
undefined
;
return
{
createFolder
:
()
=>
{
if
(
!
fs
.
existsSync
(
config
.
folder
.
audioRaw
))
{
fs
.
mkdirSync
(
config
.
folder
.
audioRaw
);
}
if
(
!
fs
.
existsSync
(
config
.
folder
.
audio
))
{
fs
.
mkdirSync
(
config
.
folder
.
audio
);
}
},
generateStream
:
()
=>
{
if
(
timestamp
===
undefined
){
timestamp
=
new
Date
().
getTime
()
}
const
name
=
uuidv1
()
const
path
=
config
.
folder
.
audioRaw
+
"
/
"
+
name
+
"
.wav
"
const
streamData
=
{
"
wstream
"
:
fs
.
createWriteStream
(
path
),
"
pathFile
"
:
path
,
"
fileName
"
:
name
,
"
timestamp
"
:
new
Date
().
getTime
()
}
return
streamData
},
endStream
:
(
streamData
)
=>
{
const
toSecond
=
1000
streamData
.
wstream
.
close
();
let
delay
=
((
timestamp
-
streamData
.
timestamp
)
/
toSecond
)
*
-
1
;
try
{
//var silence = ffmpeg().input('anullsrc=sample_rate=16000').inputFormat('lavfi').duration(delay).output(config.folder.audio+"/silence_"+streamData.fileName+".wav").run();
//var stream = ffmpeg(streamData.pathFile).toFormat(config.audio.format).noVideo().audioBitrate(config.audio.bitrate).audioChannels(config.audio.channels).audioFrequency(config.audio.srate).save(config.folder.audio+"/"+streamData.fileName+".wav")
ffmpeg
()
.
input
(
'
anullsrc=sample_rate=
'
+
config
.
audio
.
srate
)
.
inputFormat
(
'
lavfi
'
)
.
duration
(
delay
)
.
output
(
config
.
folder
.
audio
+
"
/silence_
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
end
'
,
function
()
{
ffmpeg
(
streamData
.
pathFile
)
.
toFormat
(
config
.
audio
.
format
)
.
noVideo
()
.
audioBitrate
(
config
.
audio
.
bitrate
)
.
audioChannels
(
config
.
audio
.
channels
)
.
audioFrequency
(
config
.
audio
.
srate
)
.
save
(
config
.
folder
.
audio
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
end
'
,
function
()
{
ffmpeg
()
.
input
(
config
.
folder
.
audio
+
"
/silence_
"
+
streamData
.
fileName
+
"
.wav
"
)
.
input
(
config
.
folder
.
audio
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
error
'
,
function
(
err
)
{
console
.
log
(
'
An error occurred:
'
+
err
.
message
);
})
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
Merging finished !
'
);
})
.
mergeToFile
(
config
.
folder
.
audioMerged
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
,
config
.
folder
.
audio
)
})
})
.
run
()
/*
ffmpeg(streamData.pathFile)
.toFormat(config.audio.format)
.noVideo()
.audioBitrate(config.audio.bitrate)
.audioChannels(config.audio.channels)
.audioFrequency(config.audio.srate)
.save(config.folder.audio+"/"+streamData.fileName+".wav")*/
}
catch
(
err
){
// Sometimes, the client will close the connection unexpectedly
// (e.g. when stopping). This is expected
}
}
};
};
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