forked from pubnub/javascript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsay.js
More file actions
32 lines (30 loc) · 976 Bytes
/
say.js
File metadata and controls
32 lines (30 loc) · 976 Bytes
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
/* ---------------------------------------------------------------------------
Init PubNub and Get your PubNub API Keys:
http://www.pubnub.com/account#api-keys
--------------------------------------------------------------------------- */
var pubnub = require("./../pubnub.js").init({
publish_key : "demo",
subscribe_key : "demo"
})
, exec = require('child_process').exec;
pubnub.subscribe({
channel : "my_channel",
connect : function() {
// Publish a Message on Connect
pubnub.publish({
channel : "my_channel",
message : { text : 'Ready to Receive Voice Script.' }
});
},
callback : function(message) {
console.log(message);
exec('say ' + (
'voice' in message &&
message.voice ? '-v ' +
message.voice + ' ' : ''
) + message.text);
},
error : function() {
console.log("Network Connection Dropped");
}
});