Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김승찬
/
LINEBOT
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
1
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김수민
2019-11-22 16:42:08 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2504fc6a661d229c9c361aab4e52d1413696ceab
2504fc6a
1 parent
7b1b7180
audio error correction
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
15 deletions
.idea/workspace.xml
app.js
.idea/workspace.xml
View file @
2504fc6
...
...
@@ -57,6 +57,7 @@
<workItem
from=
"1574071758382"
duration=
"6285000"
/>
<workItem
from=
"1574323490142"
duration=
"15840000"
/>
<workItem
from=
"1574342689824"
duration=
"11000"
/>
<workItem
from=
"1574396813813"
duration=
"6958000"
/>
</task>
<servers
/>
</component>
...
...
app.js
View file @
2504fc6
...
...
@@ -7,7 +7,7 @@ require("dotenv").config({path : '.env'});
var
express
=
require
(
'express'
);
var
app
=
express
();
const
line
=
require
(
'@line/bot-sdk'
);
app
.
use
(
express
.
static
(
'public'
));
//papago api
var
request
=
require
(
'request'
);
...
...
@@ -62,13 +62,13 @@ function handleEvent(event) {
return
Promise
.
resolve
(
null
);
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
//언어 감지 option
var
detect_options
=
{
url
:
languagedetect_api_url
,
form
:
{
'query'
:
event
.
message
.
text
},
headers
:
{
'X-Naver-Client-Id'
:
client_id
,
'X-Naver-Client-Secret'
:
client_secret
}
};
//papago 언어 감지
request
.
post
(
detect_options
,
function
(
error
,
response
,
body
){
console
.
log
(
response
.
statusCode
);
...
...
@@ -80,14 +80,20 @@ function handleEvent(event) {
var
audio_sys
=
{
"type"
:
"audio"
,
"originalContentUrl"
:
"https://panguin.ml/speech.m4a"
,
"duration"
:
60
000
"duration"
:
24
000
};
//언어 감지가 제대로 됐는지 확인
console
.
log
(
detect_body
.
langCode
);
if
(
detect_options
.
form
.
query
==
'음성'
){
console
.
log
(
'audio streaming'
);
for_audio_client
.
replyAudio
(
event
.
replyToken
,{
"originalContentUrl"
:
"https://panguin.ml/public/speech.m4a"
,
"duration"
:
24000
}).
then
(
resolve
).
catch
(
reject
);
}
//번역은 한국어->영어 / 영어->한국어만 지원
if
(
detect_body
.
langCode
==
'ko'
||
detect_body
.
langCode
==
'en'
){
else
if
(
detect_body
.
langCode
==
'ko'
||
detect_body
.
langCode
==
'en'
){
source
=
detect_body
.
langCode
==
'ko'
?
'ko'
:
'en'
;
target
=
source
==
'ko'
?
'en'
:
'ko'
;
//papago 번역 option
...
...
@@ -111,9 +117,10 @@ function handleEvent(event) {
//번역된 문장 보내기
client
.
replyMessage
(
event
.
replyToken
,
result
).
then
(
resolve
).
catch
(
reject
);
let
audio_options
=
{
'Text'
:
result
.
text
,
'OutputFormat'
:
'mp3'
,
'VoiceId'
:
'
Seoyeon
'
'VoiceId'
:
'
Amy
'
};
Polly
.
synthesizeSpeech
(
audio_options
,
(
err
,
data
)
=>
{
console
.
log
(
"check"
);
...
...
@@ -126,21 +133,12 @@ function handleEvent(event) {
return
console
.
log
(
err
);
}
console
.
log
(
"The file was saved!"
);
if
(
!
error
&&
response
.
statusCode
==
200
){
console
.
log
(
'audio streaming'
);
for_audio_client
.
replyAudio
(
event
.
replyToken
,
audio_sys
).
then
(
resolve
).
catch
(
reject
);
}
});
}
}
});
}
});
...
...
Please
register
or
login
to post a comment