Jinsu Park

Index.html이 아닌 node 단에서 aws-sdk 설치

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