Created
June 24, 2015 13:47
-
-
Save shyampurk/51874e459aa0c75a7b03 to your computer and use it in GitHub Desktop.
RPi Realtime Audio Broadcast
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _callback(message,channel): | |
if message["type"]=="request" : | |
print" Received message = ", message["play"] | |
status=subprocess.call(["espeak","-s 120 -v en ",message["play"]], stdout=FNULL, stderr=subprocess.STDOUT) | |
if status==0 : | |
pubnub.publish(pubnub_responsechannel, postive_response) | |
elif status!=0 : | |
pubnub.publish(pubnub_responsechannel,negative_response) | |
if message["type"]=="completed" : | |
pubnub.publish(pubnub_responsechannel, done) | |
sys.exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def process_request(): | |
sentence = importData().split(".") | |
for data in sentence : | |
print "sending message: ",data | |
request={"type" : "request" , "play" : data} | |
pubnub.publish(pubnub_requestchannel, request) | |
lock.acquire() | |
pubnub.publish(pubnub_requestchannel,complete_sentence) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _callback(message,channel): | |
if message["status"]== "positive": | |
lock.release() | |
elif message["status"]== "negative": | |
print "error in response" | |
elif message["status"]== "done": | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment