Jinsu Park

Add: basic example to use Polly

1 +<html>
2 + <head>
3 + <script src="https://sdk.amazonaws.com/js/aws-sdk-2.796.0.min.js"></script>
4 + </head>
5 + <body>
6 + <script>
7 + alert("음성을 자동으로 재생하기 위해서는 보안상 최대 한 번 페이지 내에서 액션을 취해야합니다. 페이지를 클릭해주세요.")
8 + AWS.config.region = 'ap-northeast-2';
9 + AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'ap-northeast-2:03db97c9-a857-45f3-be6e-3cf84d6f619b'});
10 + const polly = new AWS.Polly({
11 + signatureVersion: 'v4',
12 + region: 'ap-northeast-2',
13 + });
14 +
15 + let params = {
16 + 'Text': '반가워 친구야~',
17 + 'OutputFormat': 'mp3',
18 + 'VoiceId': 'Seoyeon'
19 + };
20 + let tts = new AWS.Polly.Presigner(params, polly)
21 +
22 +
23 + // Create presigned URL of synthesized speech file
24 + tts.getSynthesizeSpeechUrl(params, function(error, url) {
25 + if (error) {
26 + } else {
27 + setTimeout(()=>{
28 + console.log("실행")
29 + let audio = new Audio(url)
30 + audio.play()
31 + .then(delete audio);
32 + }, 3000)
33 + }
34 + })
35 + </script>
36 + My Polly
37 + </body>
38 +</html>
...\ No newline at end of file ...\ No newline at end of file