Showing
5 changed files
with
36 additions
and
2 deletions
This diff could not be displayed because it is too large.
| ... | @@ -8,9 +8,11 @@ | ... | @@ -8,9 +8,11 @@ |
| 8 | "@testing-library/jest-dom": "^5.11.4", | 8 | "@testing-library/jest-dom": "^5.11.4", |
| 9 | "@testing-library/react": "^11.1.0", | 9 | "@testing-library/react": "^11.1.0", |
| 10 | "@testing-library/user-event": "^12.1.10", | 10 | "@testing-library/user-event": "^12.1.10", |
| 11 | + "aws-sdk": "^2.804.0", | ||
| 11 | "react": "^17.0.1", | 12 | "react": "^17.0.1", |
| 12 | "react-dom": "^17.0.1", | 13 | "react-dom": "^17.0.1", |
| 13 | "react-scripts": "4.0.1", | 14 | "react-scripts": "4.0.1", |
| 15 | + "socket.io-client": "^3.0.3", | ||
| 14 | "web-vitals": "^0.2.4" | 16 | "web-vitals": "^0.2.4" |
| 15 | }, | 17 | }, |
| 16 | "scripts": { | 18 | "scripts": { | ... | ... |
| ... | @@ -25,8 +25,6 @@ | ... | @@ -25,8 +25,6 @@ |
| 25 | Learn how to configure a non-root public URL by running `npm run build`. | 25 | Learn how to configure a non-root public URL by running `npm run build`. |
| 26 | --> | 26 | --> |
| 27 | <title>Khuwitch</title> | 27 | <title>Khuwitch</title> |
| 28 | - | ||
| 29 | - <script src="https://sdk.amazonaws.com/js/aws-sdk-2.796.0.min.js"></script> | ||
| 30 | </head> | 28 | </head> |
| 31 | <body> | 29 | <body> |
| 32 | <noscript>You need to enable JavaScript to run this app.</noscript> | 30 | <noscript>You need to enable JavaScript to run this app.</noscript> | ... | ... |
frontend/src/tts.js
0 → 100644
| 1 | +import AWS from 'aws-sdk' | ||
| 2 | +// Polly를 사용하기 위한 자격증명을 설정한다. | ||
| 3 | +AWS.config.region = 'ap-northeast-2'; | ||
| 4 | +AWS.config.credentials = new AWS.CognitoIdentityCredentials({IdentityPoolId: 'ap-northeast-2:03db97c9-a857-45f3-be6e-3cf84d6f619b'}); | ||
| 5 | +const polly = new AWS.Polly({ | ||
| 6 | + signatureVersion: 'v4', | ||
| 7 | + region: 'ap-northeast-2', | ||
| 8 | +}); | ||
| 9 | + | ||
| 10 | +function speak(text){ | ||
| 11 | + let params = { | ||
| 12 | + 'Text': text, | ||
| 13 | + 'OutputFormat': 'mp3', | ||
| 14 | + 'VoiceId': 'Seoyeon' | ||
| 15 | + }; | ||
| 16 | + let tts = new AWS.Polly.Presigner(params, polly) | ||
| 17 | + | ||
| 18 | + // tts로 변환한 음성 파일을 얻는다. | ||
| 19 | + tts.getSynthesizeSpeechUrl(params, function(error, url) { | ||
| 20 | + if (error) { | ||
| 21 | + } else { | ||
| 22 | + setTimeout(()=>{ | ||
| 23 | + console.log("실행") | ||
| 24 | + let audio = new Audio(url) | ||
| 25 | + audio.play() | ||
| 26 | + // .then(delete audio); | ||
| 27 | + }, 3000) | ||
| 28 | + } | ||
| 29 | + }) | ||
| 30 | +} | ||
| 31 | +export default { | ||
| 32 | + "speak": speak, | ||
| 33 | +} |
| ... | @@ -10,6 +10,7 @@ | ... | @@ -10,6 +10,7 @@ |
| 10 | "author": "Daeyeonkim97", | 10 | "author": "Daeyeonkim97", |
| 11 | "license": "ISC", | 11 | "license": "ISC", |
| 12 | "dependencies": { | 12 | "dependencies": { |
| 13 | + "cors": "^2.8.5", | ||
| 13 | "dotenv": "^8.2.0", | 14 | "dotenv": "^8.2.0", |
| 14 | "ejs": "^3.1.5", | 15 | "ejs": "^3.1.5", |
| 15 | "express": "^4.17.1", | 16 | "express": "^4.17.1", | ... | ... |
-
Please register or login to post a comment