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:01:30 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a3b6fc427be3d512a1100ec34e6bea114b265a90
a3b6fc42
1 parent
ee9e8644
write 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
0 → 100644
View file @
a3b6fc4
const
apiRequest
=
require
(
'./apiRequest'
);
const
isBase64
=
require
(
'is-base64'
);
//const Lame = require("node-lame").Lame;
const
fs
=
require
(
"fs"
);
//const Mp32Wav = require('mp3-to-wav')
const
apiReq
=
async
(
clientData
)
=>
{
fs
.
writeFileSync
(
'./audio/audio_input.mp3'
,
Buffer
.
from
(
clientData
.
audio
.
replace
(
'data:audio/mp3; codecs=opus;base64,'
,
''
),
'base64'
));
const
mp32Wav
=
new
Mp32Wav
(
'./audio/audio_input.mp3'
)
mp32Wav
.
saveForWav
(
Buffer
.
from
(
clientData
.
audio
.
replace
(
'data:audio/mp3; codecs=opus;base64,'
,
''
),
'base64'
),
'./audio/audio_input.wav'
,
_
,
16000
,
1
)
//let audiodata = fs.readFileSync('./audio/audio_input.mp3').toString('base64')
console
.
log
(
Buffer
(
clientData
.
audio
,
'base64'
))
getSTT
=
await
apiRequest
.
ETRI
(
"WiseASR/Recognition"
,
{
"language_code"
:
"korean"
,
"audio"
:
audiodata
}
);
return
{
"text"
:
getSTT
.
return_object
.
recognized
};
}
const
STT
=
async
(
req
,
res
)
=>
{
let
clientData
,
voiceTemp
;
clientData
=
req
.
body
.
data
voiceTemp
=
await
apiReq
(
clientData
);
res
.
send
(
{
"return_code"
:
0
,
"return_data"
:
voiceTemp
}
);
res
.
status
(
200
);
};
module
.
exports
=
STT
;
\ No newline at end of file
Please
register
or
login
to post a comment