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-21 22:25:23 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7b1b7180d67b76f43d8eba4a9eb80bbc594a0d5a
7b1b7180
1 parent
7467c9d8
audio commit
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
16 deletions
.idea/workspace.xml
app.js
.idea/workspace.xml
View file @
7b1b718
...
...
@@ -4,8 +4,6 @@
<list
default=
"true"
id=
"5c08ae96-2f87-46c1-b81d-f30e494ce252"
name=
"Default Changelist"
comment=
""
>
<change
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/app.js"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/app.js"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/package-lock.json"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/package-lock.json"
afterDir=
"false"
/>
<change
beforePath=
"$PROJECT_DIR$/package.json"
beforeDir=
"false"
afterPath=
"$PROJECT_DIR$/package.json"
afterDir=
"false"
/>
</list>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
<option
name=
"SHOW_DIALOG"
value=
"false"
/>
...
...
@@ -57,7 +55,8 @@
<workItem
from=
"1573898557106"
duration=
"89000"
/>
<workItem
from=
"1573899005304"
duration=
"7410000"
/>
<workItem
from=
"1574071758382"
duration=
"6285000"
/>
<workItem
from=
"1574323490142"
duration=
"7902000"
/>
<workItem
from=
"1574323490142"
duration=
"15840000"
/>
<workItem
from=
"1574342689824"
duration=
"11000"
/>
</task>
<servers
/>
</component>
...
...
app.js
View file @
7b1b718
...
...
@@ -37,7 +37,7 @@ const config = {
// create LINE SDK client
const
client
=
new
line
.
Client
(
config
);
const
for_audio_client
=
LineClient
.
connect
({
channelA
ccessToken
:
process
.
env
.
channelAccessToken
,
a
ccessToken
:
process
.
env
.
channelAccessToken
,
channelSecret
:
process
.
env
.
channelSecret
,
});
// create Express app
...
...
@@ -77,7 +77,11 @@ function handleEvent(event) {
var
source
=
''
;
var
target
=
''
;
var
result
=
{
type
:
'text'
,
text
:
''
};
var
audio_sys
=
{
"type"
:
"audio"
,
"originalContentUrl"
:
"https://panguin.ml/speech.m4a"
,
"duration"
:
60000
};
//언어 감지가 제대로 됐는지 확인
console
.
log
(
detect_body
.
langCode
);
...
...
@@ -105,6 +109,7 @@ function handleEvent(event) {
result
.
text
=
objBody
.
message
.
result
.
translatedText
;
console
.
log
(
result
.
text
);
//번역된 문장 보내기
client
.
replyMessage
(
event
.
replyToken
,
result
).
then
(
resolve
).
catch
(
reject
);
let
audio_options
=
{
'Text'
:
result
.
text
,
'OutputFormat'
:
'mp3'
,
...
...
@@ -116,26 +121,26 @@ function handleEvent(event) {
throw
err
;
}
else
if
(
data
)
{
if
(
data
.
AudioStream
instanceof
Buffer
)
{
fs
.
writeFile
(
"
./speech.mp3
"
,
data
.
AudioStream
,
function
(
err
)
{
fs
.
writeFile
(
"
public/speech.m4a
"
,
data
.
AudioStream
,
function
(
err
)
{
if
(
err
)
{
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
);
}
});
}
}
});
request
.
post
(
audio_options
,
function
(
error
,
response
,
body
)
{
if
(
!
error
&&
response
.
statusCode
==
200
){
for_audio_client
.
replyAudio
(
event
.
replyToken
,{
originalContentUrl
:
'https://panguin.ml/speech.mp3'
,
duration
:
240000
}).
then
(
resolve
).
catch
(
reject
);
}
});
client
.
replyMessage
(
event
.
replyToken
,
result
).
then
(
resolve
).
catch
(
reject
);
}
});
...
...
Please
register
or
login
to post a comment