Toggle navigation
Toggle navigation
This project
Loading...
Sign in
윤창신
/
searchGuide
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
윤창신
2019-12-03 19:06:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e39f8402b49073a054bcace9220fa9a2c0528af0
e39f8402
1 parent
c2e7e947
fix STT.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
api/STT.js
api/STT.js
View file @
e39f840
...
...
@@ -11,7 +11,14 @@ const apiReq = async ( clientData ) => {
//let audiodata = fs.readFileSync('./audio/audio_input.mp3').toString('base64')
console
.
log
(
Buffer
(
clientData
.
audio
,
'base64'
))
let
getSTT
=
{};
try
{
getSTT
=
await
apiRequest
.
ETRI
(
"WiseASR/Recognition"
,
{
"language_code"
:
"korean"
,
"audio"
:
audiodata
}
);
}
catch
(
err
)
{
throw
new
Error
(
err
.
message
);
}
return
{
"text"
:
getSTT
.
return_object
.
recognized
};
}
...
...
@@ -20,8 +27,31 @@ const STT = async ( req, res ) => {
let
clientData
,
voiceTemp
;
try
{
clientData
=
req
.
body
.
data
if
(
!
clientData
.
audio
.
length
)
{
throw
new
Error
(
"client audio empty"
);
}
else
if
(
!
isBase64
(
clientData
.
audio
)
)
{
throw
new
Error
(
"Type error : audio type should be base64"
);
}
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
json
(
{
"return_code"
:
-
1
,
"error_code"
:
err
.
message
}
);
res
.
status
(
403
);
return
false
;
}
try
{
voiceTemp
=
await
apiReq
(
clientData
);
}
catch
(
err
)
{
console
.
log
(
err
);
res
.
json
(
{
"return_code"
:
-
1
,
"error_code"
:
err
.
message
}
);
res
.
status
(
502
);
return
false
;
}
res
.
send
(
{
"return_code"
:
0
,
"return_data"
:
voiceTemp
}
);
res
.
status
(
200
);
...
...
Please
register
or
login
to post a comment