Skip to content

Instantly share code, notes, and snippets.

View CPsridharCP's full-sized avatar
💭
Fun with Robots !!

Sridhar Cuddalore Parthasarathy CPsridharCP

💭
Fun with Robots !!
View GitHub Profile
misty.MoveHeadDegrees(0, 0, 0, 30);
_subscribeToBackpackData();
function _subscribeToBackpackData()
{
misty.ChangeLED(0, 0, 255);
misty.DisplayImage("e_DefaultContent.jpg");
misty.AddReturnProperty("backpackMessage", "SerialMessage");
misty.RegisterEvent("backpackMessage", "SerialMessage", 50, false);
}
polly = boto3.client('polly')
response = polly.synthesize_speech(OutputFormat='mp3',Text = text,VoiceId = "Salli")
if "AudioStream" in response:
with closing(response["AudioStream"]) as stream:
audio = base64.encodebytes(stream.read())
out = str(audio.decode("ascii")).replace('\n', '')
logger.info(out)
logger.info(len(out))
else if (data.type == 'say')
{
var base64 = data.say;
var next = data.next;
misty.Debug(next);
misty.Debug(typeof next);
if (next == "None")
{
misty.RegisterTimerEvent("keepActive", 18000, true);
function _keepActive() {
misty.SendExternalRequest("POST", "https://ps.pndsn.com/publish/<publish-key>/<subscribe-key>/0/<pubnub-channel>/myCallback", null, null, "{}", false, false, "", "application/json");
}
misty.SendExternalRequest("GET", "https://ps.pndsn.com/subscribe/<subscribe-key>/<pubnub-channel>/0/0?uuid=<any-user-name>", null, null, "{}", false, false, "", "application/json", "_pubNubSubscribe");
function _pubNubSubscribe(data)
{
{
"actions": [
{
"redirect": "https://<twilio-function-endpoint>.twil.io/say"
}
]
}
exports.handler = function(context, event, callback) {
var parameter = event.CurrentInput.substr(event.CurrentInput.indexOf(" ") + 1);
console.log(parameter);
const replySms = parameter != 'You are amazing !' ? {"actions": [{"say": "[••] Speaking "+parameter+"!"}]} : {"actions": [{"say": "[••] Sorry i did't understand, What should i say again"}]}
const replyErrorSms = {"actions": [{"say": "[••] Oops an error occured, Could you please try again.."}]};
const axios = require('axios')