Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
linstt-controller
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LINAGORA
L
LGS
Labs
linstt-controller
Commits
f86cb660
Commit
f86cb660
authored
Jan 05, 2018
by
Yoann HOUPERT
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow to use offline transcrib
parent
0e2091bf
Pipeline
#9401
failed with stage
in 26 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
15 deletions
+87
-15
config.json
config.json
+8
-0
lib/controller/offline.js
lib/controller/offline.js
+53
-0
lib/webserver/routes.js
lib/webserver/routes.js
+24
-14
package.json
package.json
+2
-1
No files found.
config.json
View file @
f86cb660
...
...
@@ -2,6 +2,7 @@
"api"
:
3000
,
"apiSsl"
:
3001
,
"orchestrator"
:
{
"isOffline"
:
false
,
"gstreamer"
:
{
"host"
:
"linsttpoc_kaldi_1"
,
"host2"
:
"linsttcontroller_kaldi_1"
,
...
...
@@ -10,6 +11,13 @@
"recognize"
:
"client/dynamic/recognize"
}
},
"offline"
:
{
"host"
:
"linsttpoc_offline_1"
,
"port"
:
"5000"
,
"api"
:
{
"upload"
:
"upload"
}
},
"speechEnhancement"
:
{
"host"
:
"linsttpoc_speech-enhencement_1"
,
"host2"
:
"linsttcontroller_speech-enhencement_1"
,
...
...
lib/controller/offline.js
0 → 100644
View file @
f86cb660
/*
* Copyright (c) 2017 Linagora.
*
* This file is part of linstt-controller
* (see https://ci.linagora.com/linagora/lgs/labs/linstt-controller).
*
* 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/>.
*/
module
.
exports
=
config
=>
{
const
request
=
require
(
'
request
'
);
const
uuidv1
=
require
(
'
uuid/v1
'
);
return
{
transcript
:
(
wavFile
,
enhancementlCallback
)
=>
{
const
url
=
'
http://
'
+
config
.
host
+
'
:
'
+
config
.
port
+
'
/
'
+
config
.
api
.
upload
;
const
uiid
=
uuidv1
();
let
myUuidString
=
uiid
.
toString
();
let
re
=
/-/g
;
myUuidString
=
re
[
Symbol
.
replace
](
myUuidString
,
''
);
const
options
=
{
url
,
formData
:
{
wavFile
:
{
value
:
wavFile
,
options
:
{
filename
:
myUuidString
,
contentType
:
'
audio/x-wav
'
}
}
},
encoding
:
null
};
request
.
post
(
options
,
enhancementlCallback
);
return
wavFile
;
}
};
};
lib/webserver/routes.js
View file @
f86cb660
...
...
@@ -23,6 +23,7 @@ const routesFactory = config => {
const
routes
=
require
(
'
express
'
).
Router
();
const
enhancer
=
require
(
'
../controller/speech-enhancement
'
)(
config
.
speechEnhancement
);
const
stt
=
require
(
'
../controller/speech-to-text
'
)(
config
.
gstreamer
);
const
offline
=
require
(
'
../controller/offline
'
)(
config
.
offline
);
routes
.
post
(
'
/api/transcript
'
,
(
req
,
res
)
=>
{
if
(
!
req
.
body
)
{
...
...
@@ -34,22 +35,31 @@ const routesFactory = config => {
return
res
.
status
(
500
).
send
(
'
Error while enhancing audio.
'
+
err
);
}
stt
.
transcript
(
body
,
(
err
,
httpResponse
,
body
)
=>
{
if
(
err
)
{
return
res
.
status
(
500
).
send
(
'
Error while transcript the audio.
'
+
err
);
}
else
if
(
body
.
indexOf
(
'
No workers available
'
)
!==
-
1
)
{
return
res
.
status
(
500
).
send
(
'
No worker available for the moment.
'
);
}
if
(
config
.
isOffline
){
offline
.
transcript
(
body
,
(
err
,
httpResponse
,
body
)
=>
{
const
json
=
JSON
.
parse
(
body
);
if
(
json
.
status
===
5
)
{
return
res
.
status
(
500
).
send
(
'
Error while transcript the audio.
'
);
}
return
res
.
status
(
200
).
json
({
message
:
'
transcript done
'
,
hypotheses
:
json
});
});
const
json
=
JSON
.
parse
(
body
);
if
(
json
.
status
===
5
)
{
return
res
.
status
(
500
).
send
(
'
Error while transcript the audio.
'
);
}
return
res
.
status
(
200
).
json
({
message
:
'
transcript done
'
,
transcript
:
json
});
}
else
{
stt
.
transcript
(
body
,
(
err
,
httpResponse
,
body
)
=>
{
if
(
err
)
{
return
res
.
status
(
500
).
send
(
'
Error while transcript the audio.
'
+
err
);
}
else
if
(
body
.
indexOf
(
'
No workers available
'
)
!==
-
1
)
{
return
res
.
status
(
500
).
send
(
'
No worker available for the moment.
'
);
}
const
json
=
JSON
.
parse
(
body
);
if
(
json
.
status
===
5
)
{
return
res
.
status
(
500
).
send
(
'
Error while transcript the audio.
'
);
}
return
res
.
status
(
200
).
json
({
message
:
'
transcript done
'
,
transcript
:
json
});
});
}
);
}
);
});
});
return
routes
;
};
...
...
package.json
View file @
f86cb660
...
...
@@ -14,7 +14,8 @@
"
body-parser
"
:
"
^1.18.2
"
,
"
express
"
:
"
^4.16.2
"
,
"
express-fileupload
"
:
"
^0.3.0
"
,
"
request
"
:
"
^2.83.0
"
"
request
"
:
"
^2.83.0
"
,
"
uuid
"
:
"
^3.1.0
"
},
"devDependencies"
:
{
"
jest
"
:
"
20.0.0
"
,
...
...
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