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
b0d4ba4e
Commit
b0d4ba4e
authored
Apr 18, 2018
by
Yoann HOUPERT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add transcription offline
parent
00848f7a
Pipeline
#14046
failed with stage
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
110 additions
and
66 deletions
+110
-66
.env
.env
+2
-2
config.json
config.json
+6
-3
lib/proxy.js
lib/proxy.js
+2
-4
lib/resume.js
lib/resume.js
+100
-57
No files found.
.env
View file @
b0d4ba4e
MODELS_PATH=./models/current_model/model/
MODELS_PATH=./models/current_model/
hublot_
model/
MODEL_PATH_OFFLINE=./models/current_model/
OFFLINE_PORT=
9050
OFFLINE_PORT=
8888
YAML=/opt/models/gmm_hmm3.yaml
NB_WORKERS=2
ASD_SERVER_IP="localhost"
...
...
config.json
View file @
b0d4ba4e
...
...
@@ -64,8 +64,11 @@
"channels"
:
1
,
"srate"
:
16000
},
"host"
:
"hublot_offline_1"
,
"port"
:
9999
,
"model"
:
"current_model"
"host"
:
"hublot_offline-server_1"
,
"port"
:
8888
,
"model"
:
"hublot_model"
,
"api"
:{
"upload"
:
"upload"
}
}
}
lib/proxy.js
View file @
b0d4ba4e
...
...
@@ -97,6 +97,8 @@ module.exports = config => {
connectionToClient
.
send
(
xmlHttp
.
responseText
);
}
catch
(
err
)
{
console
.
error
(
'
proxy: recoRecoWS error
'
,
err
);
console
.
error
(
'
It is probably already close
'
,);
}
}
else
{
console
.
error
(
'
Online reco: error trying to reach http://%s:%s/resources
'
,
...
...
@@ -131,9 +133,6 @@ module.exports = config => {
// (e.g. when stopping). This is expected
}
});
connectionToKaldi
.
on
(
'
close
'
,
()
=>
{
connectionToClient
.
close
()
});
});
return
connectionToKaldi
;
}
...
...
@@ -179,7 +178,6 @@ module.exports = config => {
}
else
{
transcriptor
.
streamPush
(
thisUserStream
,
data
)
}
console
.
log
(
'
stream data save
'
)
streamData
.
wstream
.
write
(
data
);
})
...
...
lib/resume.js
View file @
b0d4ba4e
...
...
@@ -22,13 +22,16 @@ const uuidv1 = require('uuid/v1');
const
request
=
require
(
'
request
'
);
const
ffmpegInstaller
=
require
(
'
@ffmpeg-installer/ffmpeg
'
);
const
ffprobeInstaller
=
require
(
'
@ffprobe-installer/ffprobe
'
);
const
ffprobeInstaller
=
require
(
'
@ffprobe-installer/ffprobe
'
);
const
ffmpeg
=
require
(
'
fluent-ffmpeg
'
);
ffmpeg
.
setFfmpegPath
(
ffmpegInstaller
.
path
);
ffmpeg
.
setFfprobePath
(
ffprobeInstaller
.
path
);
const
successCode
=
200
;
const
interalServerCode
=
500
;
module
.
exports
=
ffmpeg
;
module
.
exports
=
config
=>
{
...
...
@@ -36,27 +39,67 @@ module.exports = config => {
let
timestamp
=
undefined
;
let
userConf
=
0
;
function
offlineTranscription
(){
//TODO
function
offlineTranscription
(
enhancementlCallback
)
{
let
port
=
config
.
port
;
if
(
process
.
env
.
OFFLINE_PORT
!==
undefined
)
{
port
=
process
.
env
.
OFFLINE_PORT
;
}
const
url
=
'
http://
'
+
config
.
host
+
'
:
'
+
port
+
'
/
'
+
config
.
api
.
upload
;
const
uiid
=
uuidv1
();
let
myUuidString
=
uiid
.
toString
();
const
re
=
/-/g
;
myUuidString
=
re
[
Symbol
.
replace
](
myUuidString
,
''
);
const
options
=
{
url
,
formData
:
{
wavFile
:
{
value
:
fs
.
ReadStream
(
config
.
folder
.
audioMerged
+
'
/merged.wav
'
),
options
:
{
filename
:
myUuidString
,
contentType
:
'
audio/x-wav
'
}
},
model
:
config
.
model
},
encoding
:
null
};
request
.
post
(
options
,
enhancementlCallback
);
}
function
resumeGenerator
(){
function
resumeGenerator
()
{
let
nbFile
=
0
;
let
cmd
=
ffmpeg
()
fs
.
readdirSync
(
config
.
folder
.
audioMerged
).
forEach
(
file
=>
{
cmd
.
input
(
config
.
folder
.
audioMerged
+
"
/
"
+
file
)
cmd
.
input
(
config
.
folder
.
audioMerged
+
"
/
"
+
file
)
nbFile
++
;
})
cmd
.
complexFilter
(
'
amix=inputs=
'
+
nbFile
+
'
:duration=first:dropout_transition=3
'
)
.
save
(
config
.
folder
.
audioMerged
+
"
/merged.wav
"
)
.
on
(
'
end
'
,
function
()
{
})
cmd
.
complexFilter
(
'
amix=inputs=
'
+
nbFile
+
'
:duration=first:dropout_transition=3
'
)
.
save
(
config
.
folder
.
audioMerged
+
"
/merged.wav
"
)
.
on
(
'
end
'
,
function
()
{
offlineTranscription
((
err
,
response
,
body
)
=>
{
let
result
;
if
(
err
)
{
result
=
{
module
:
'
Offline transcription
'
,
error
:
'
Error during audio transcription
'
,
info
:
err
.
toString
()}
}
else
if
(
response
===
undefined
||
body
===
undefined
||
response
.
statusCode
!==
successCode
)
{
result
=
{
module
:
'
Offline transcription
'
,
error
:
'
Error during audio transcription
'
}
}
const
json
=
JSON
.
parse
(
body
);
if
(
json
.
status
===
5
)
{
result
=
{
module
:
'
Offline transcription
'
,
error
:
'
Error during audio transcription
'
}
}
const
transcription
=
json
.
transcript
.
transcription
;
console
.
log
(
transcription
)
})
})
}
return
{
createFolder
:
()
=>
{
createFolder
:
()
=>
{
if
(
!
fs
.
existsSync
(
config
.
folder
.
audioRaw
))
{
fs
.
mkdirSync
(
config
.
folder
.
audioRaw
);
}
...
...
@@ -67,67 +110,67 @@ module.exports = config => {
fs
.
mkdirSync
(
config
.
folder
.
audioMerged
);
}
},
generateStream
:
()
=>
{
if
(
timestamp
===
undefined
)
{
generateStream
:
()
=>
{
if
(
timestamp
===
undefined
)
{
timestamp
=
new
Date
().
getTime
()
}
const
name
=
uuidv1
()
const
path
=
config
.
folder
.
audioRaw
+
"
/
"
+
name
+
"
.wav
"
const
path
=
config
.
folder
.
audioRaw
+
"
/
"
+
name
+
"
.wav
"
const
streamData
=
{
"
wstream
"
:
fs
.
createWriteStream
(
path
),
"
pathFile
"
:
path
,
"
wstream
"
:
fs
.
createWriteStream
(
path
),
"
pathFile
"
:
path
,
"
fileName
"
:
name
,
"
timestamp
"
:
new
Date
().
getTime
()
"
timestamp
"
:
new
Date
().
getTime
()
}
userConf
++
return
streamData
},
endStream
:
(
streamData
)
=>
{
endStream
:
(
streamData
)
=>
{
const
toSecond
=
1000
streamData
.
wstream
.
close
();
let
delay
=
((
timestamp
-
streamData
.
timestamp
)
/
toSecond
)
*
-
1
;
try
{
try
{
console
.
log
(
'
generate silence
'
)
ffmpeg
()
.
input
(
'
anullsrc=sample_rate=
'
+
config
.
audio
.
srate
)
.
inputFormat
(
'
lavfi
'
)
.
duration
(
delay
)
.
output
(
config
.
folder
.
audioWav
+
"
/silence_
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
generate audio file
'
)
ffmpeg
(
streamData
.
pathFile
)
.
toFormat
(
config
.
audio
.
format
)
.
noVideo
()
.
audioBitrate
(
config
.
audio
.
bitrate
)
.
audioChannels
(
config
.
audio
.
channels
)
.
audioFrequency
(
config
.
audio
.
srate
)
.
save
(
config
.
folder
.
audioWav
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
error
'
,
function
(
err
)
{
--
userConf
console
.
log
(
'
An error occurred:
'
+
err
.
message
);
})
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
merge audio and silence
'
)
ffmpeg
()
.
input
(
config
.
folder
.
audioWav
+
"
/silence_
"
+
streamData
.
fileName
+
"
.wav
"
)
.
input
(
config
.
folder
.
audioWav
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
error
'
,
function
(
err
)
{
console
.
log
(
'
An error occurred:
'
+
err
.
message
);
})
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
Merging finished !
'
+
streamData
.
fileName
);
if
(
--
userConf
===
0
){
console
.
log
(
'
generate room audio
'
)
resumeGenerator
(
config
)
}
})
.
mergeToFile
(
config
.
folder
.
audioMerged
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
,
config
.
folder
.
audio
)
.
input
(
'
anullsrc=sample_rate=
'
+
config
.
audio
.
srate
)
.
inputFormat
(
'
lavfi
'
)
.
duration
(
delay
)
.
output
(
config
.
folder
.
audioWav
+
"
/silence_
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
generate audio file
'
)
ffmpeg
(
streamData
.
pathFile
)
.
toFormat
(
config
.
audio
.
format
)
.
noVideo
()
.
audioBitrate
(
config
.
audio
.
bitrate
)
.
audioChannels
(
config
.
audio
.
channels
)
.
audioFrequency
(
config
.
audio
.
srate
)
.
save
(
config
.
folder
.
audioWav
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
error
'
,
function
(
err
)
{
--
userConf
console
.
log
(
'
An error occurred:
'
+
err
.
message
);
})
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
merge audio and silence
'
)
ffmpeg
()
.
input
(
config
.
folder
.
audioWav
+
"
/silence_
"
+
streamData
.
fileName
+
"
.wav
"
)
.
input
(
config
.
folder
.
audioWav
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
)
.
on
(
'
error
'
,
function
(
err
)
{
console
.
log
(
'
An error occurred:
'
+
err
.
message
);
})
.
on
(
'
end
'
,
function
()
{
console
.
log
(
'
Merging finished !
'
+
streamData
.
fileName
);
if
(
--
userConf
===
0
)
{
console
.
log
(
'
generate room audio
'
)
resumeGenerator
(
config
)
}
})
.
mergeToFile
(
config
.
folder
.
audioMerged
+
"
/
"
+
streamData
.
fileName
+
"
.wav
"
,
config
.
folder
.
audio
)
})
})
})
.
run
()
}
catch
(
err
){
.
run
()
}
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