-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
53 lines (43 loc) · 1.54 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
(function() {
'use strict';
angular
.module('myApp')
.controller('YourCtrl', YourCtrl);
YourCtrl.$inject = ['$timeout'];
function YourCtrl($timeout) {
function ssmlToSpeech() {
// Set your credentials
AWS.config.region = 'xxx';
AWS.config.accessKeyId = 'xxxxxxxxx';
AWS.config.secretAccessKey = 'xxxxxxxxxxxxxxxxxxxxxx';
var polly = new AWS.Polly();
var params = {
OutputFormat: 'mp3', /* required */
Text: ` <speak>
hisaaaa ssd<break time="1s"/>
In the middle of the 10/3/2014 <sub alias="World Wide Web Consortium">W3C</sub> meeting
he shouted, "Score!" quite loudly. When his boss stared at him, he repeated
<amazon:effect name="whispered">"Score"</amazon:effect> in a whisper.
</speak>`, /* required */
VoiceId: 'Joanna', /* required */
SampleRate: '22050',
TextType: 'ssml'
};
polly.synthesizeSpeech(params, function(err, data) {
if (err) {
console.log(err);
} else {
console.log('stream ', data);
var blob = new Blob([data.AudioStream], {type : data.ContentType});
$timeout(function() {
var reader = new FileReader();
reader.onload = function(e) {
angular.element("#your_html_element").attr("src", e.target.result);
};
reader.readAsDataURL(blob);
});
}
});
}
}
})()