Skip to content
GitLab
Explore
Sign in
Commits on Source (2)
add model id to request
· 92329ddb
Yoann HOUPERT
authored
Feb 27, 2018
92329ddb
manage conflict
· 995a34a7
Yoann HOUPERT
authored
Feb 28, 2018
995a34a7
Hide whitespace changes
Inline
Side-by-side
lib/controller/offline.js
View file @
995a34a7
...
...
@@ -23,7 +23,7 @@ module.exports = config => {
const
uuidv1
=
require
(
'
uuid/v1
'
);
return
{
transcript
:
(
wavFile
,
enhancementlCallback
)
=>
{
transcript
:
(
wavFile
,
model
,
enhancementlCallback
)
=>
{
let
port
=
config
.
port
;
if
(
process
.
env
.
OFFLINE_PORT
!==
undefined
)
{
port
=
process
.
env
.
OFFLINE_PORT
;
...
...
@@ -45,7 +45,8 @@ module.exports = config => {
filename
:
myUuidString
,
contentType
:
'
audio/x-wav
'
}
}
},
model
},
encoding
:
null
};
...
...
lib/webserver/routes.js
View file @
995a34a7
...
...
@@ -33,7 +33,7 @@ const routesFactory = config => {
const
stt
=
require
(
'
../controller/speech-to-text
'
)(
config
.
gstreamer
);
const
offline
=
require
(
'
../controller/offline
'
)(
config
.
offline
);
routes
.
post
(
'
/api/transcript
'
,
(
req
,
res
)
=>
{
routes
.
post
(
'
/api/transcript
/:model*?
'
,
(
req
,
res
)
=>
{
if
(
!
req
.
body
)
{
return
res
.
status
(
badRequestCode
).
send
(
'
No files were uploaded.
'
);
}
...
...
@@ -41,6 +41,9 @@ const routesFactory = config => {
if
(
req
.
get
(
'
content-type
'
)
===
undefined
)
{
return
res
.
status
(
noContentTypeCode
).
send
(
'
No content type given
'
);
}
if
(
req
.
params
.
model
===
undefined
)
{
req
.
params
.
model
=
'
uc1
'
;
}
enhancer
.
enhancement
(
req
.
body
,
(
err
,
response
,
body
)
=>
{
if
(
err
)
{
...
...
@@ -50,7 +53,7 @@ const routesFactory = config => {
}
if
(
process
.
env
.
IS_OFFLINE
===
'
true
'
||
(
process
.
env
.
IS_OFFLINE
===
undefined
&&
config
.
isOffline
===
true
))
{
offline
.
transcript
(
body
,
(
err
,
response
,
body
)
=>
{
offline
.
transcript
(
body
,
req
.
params
.
model
,
(
err
,
response
,
body
)
=>
{
if
(
err
)
{
return
res
.
status
(
interalServerCode
).
json
({
module
:
'
Offline transcription
'
,
error
:
'
Error during audio transcription
'
,
info
:
err
.
toString
()});
}
else
if
(
response
===
undefined
||
body
===
undefined
||
response
.
statusCode
!==
successCode
)
{
...
...
@@ -64,7 +67,6 @@ const routesFactory = config => {
const
jsonStr
=
json
.
transcript
.
transcription
;
let
jsonResponse
=
{};
try
{
const
transcription
=
JSON
.
parse
(
json
.
transcript
.
transcription
);
...
...