plamoni / SiriProxy

A (tampering) proxy server for Apple's Siri
GNU General Public License v3.0
2.12k stars 343 forks source link

Sometimes siriproxy send messages to Guzzoni after the plugin recognizes the SpeechPacket #528

Closed GWayneC closed 11 years ago

GWayneC commented 11 years ago

I am sorry if I am posting this in the wrong place, but here is my issue. I am currently using the SiriProxy image for the Paspberry PI provided byElvis Impersonator, I modified the example plugin to send commands to a web service that I build for Home automation. So I could say "good night" or "Computer good night" and I expect siripoxy to send the text "good night" to the web service and respond with "Good night Wayne, sweet dreams," However although the plugin calls the webservice and the commands are executed, the request also seems to go to guzzoni as well and Siri repsonds as follows "I found x computer stores nearby, n of them are fairly close to you"

Thnaks for you help/suggestions.

elvisimprsntr commented 11 years ago

Your problem is likely the regex syntax you are using for the listen statement. If SiriProxy did respond as you expected then SiriProxy did not not find a match and simply passed on the response from Apple Siri.

GWayneC commented 11 years ago

Thanks for you answer, but I am confused "If SiriProxy did respond as you expected then SiriProxy did not not find a match"
My problem is simply this I say "light out" and the lights go out, but Siri says "Wayne, I do not understand 'lights out', do you want me to do a web search for lights out"

elvisimprsntr commented 11 years ago

Correction. I meant to state "if Siriproxy did not..." But you got the message.

You answered you own question. Light vs lights. The regex expression needs to be a direct match. You can add an or expression or simply add another listen statement. Read up on regex or look at other examples.

Elvis

On May 28, 2013, at 13:25, GWayneC notifications@github.com wrote:

Thanks for you answer, but I am confused "If SiriProxy did respond as you expected then SiriProxy did not not find a match"

My problem is simply this I say "light out" and the lights go out, but Siri says "Wayne, I do not understand 'lights out', do you want me to do a web search for lights out"

GWayneC commented 11 years ago

Sorry to be a pin, and thanks for the Raspberry PI version which is what I am using. My response also included s typo.. It should have said "I say _'lights ou_t' and the lights go out, but Siri says "Wayne, I do not understand 'lights out...',

Either way my understanding was that either the plugin handled the speech or Guzzoni did but not both. And since when I say "lights out" my plugin turned the lights off, then I would not expect Siri to say ".. I do not understand 'lights out', do you want me to do a web search for lights out"

Am I totally off base in my thinking?

Thanks and regards

On Tue, May 28, 2013 at 2:08 PM, Elvis notifications@github.com wrote:

Correction. I meant to state "if Siriproxy did not..." But you got the message.

You answered you own question. Light vs lights. The regex expression needs to be a direct match. You can add an or expression or simply add another listen statement. Read up on regex or look at other examples.

Elvis

On May 28, 2013, at 13:25, GWayneC notifications@github.com wrote:

Thanks for you answer, but I am confused "If SiriProxy did respond as you expected then SiriProxy did not not find a match"

My problem is simply this I say "light out" and the lights go out, but Siri says "Wayne, I do not understand 'lights out', do you want me to do a web search for lights out"

— Reply to this email directly or view it on GitHubhttps://github.com/plamoni/SiriProxy/issues/528#issuecomment-18568989 .

Garfield (Wayne) Cousins

“Vision without action is a daydream. Action without vision is a nightmare.” -Japanese Proverb

elvisimprsntr commented 11 years ago

It's had to troubleshoot without seeing your code. Perhaps you are missing a request_completed statement?

GWayneC commented 11 years ago

OK, here is the main script file; the one with the rb extension is the one giving me trouble, the one with the .txt extension is my attempt to clean up and simplify. I apologize in advance for any I am still learning her, and I usually cleanup my code one I get everything working, I also what to thank you for your examples, I have been using othe one that pushed the cam pictures as an example for loading device info from a zwave web service.. but I haven;t got it to work yet.

On Tue, May 28, 2013 at 2:20 PM, Elvis notifications@github.com wrote:

It's had to troubleshoot without seeing your code. Perhaps you are missing a request_completed statement?

— Reply to this email directly or view it on GitHubhttps://github.com/plamoni/SiriProxy/issues/528#issuecomment-18569831 .

Garfield (Wayne) Cousins

“Vision without action is a daydream. Action without vision is a nightmare.” -Japanese Proverb

`require 'rest_client'

require 'httparty'

require 'json'

require 'cora' require 'siri_objects' require 'pp'

#######

Remember to add other plugins to the "config.yml" file if you create them!

class SiriProxy::Plugin::Rosie < SiriProxy::Plugin def initialize(config)

if you have custom configuration options, process them here!

end

get the user's location and display it in the logs

filters are still in their early stages. Their interface may be modified

filter "SetRequestOrigin", direction: :from_iphone do |object| puts "[Info - User Location] lat: #{object["properties"]["latitude"]}, long: #{object["properties"]["longitude"]}"

#Note about returns from filters:
# - Return false to stop the object from being forwarded
# - Return a Hash to substitute or update the object
# - Return nil (or anything not a Hash or false) to have the object forwarded (along with any
#    modifications made to it)

end

listen_for /where am i/i do say "Your location is: #{location.address}" end listen_for /Rosie are you there/i do say "Rosie is at your service", spoken: "Yes, Wayne, I am here, ready to do your bidding" request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

listen_for /Computer are you online/i do say "Rosie is at your service", spoken: "Yes, I am online and ready to accept requests" request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

Demonstrate that you can have Siri say one thing and write another"!

listen_for /you don't say/i do say "Sometimes I don't write what I say", spoken: "Sometimes I don't say what I write" request_completed end

demonstrate state change

listen_for /siri proxy test state/i do set_state :some_state #set a state... this is useful when you want to change how you respond after certain conditions are met! say "I set the state, try saying 'confirm state change'" request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

listen_for /confirm state change/i, within_state: :some_state do #this only gets processed if you're within the :some_state state! say "State change works fine!" set_state nil #clear out the state!

request_completed #always complete your request! Otherwise the phone will "spin" at the user!

end

fun stuff

listen_for /is the fairest of them all/i do say "The answer is obvious, your lovely wife Joan, is the fairest of them all" request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

Consume rosie service

# listen_for /rosie|computer/i do response = ask "Hi Wayne, what can I do for you?" if(response =~ /What is the temperature/i) #process their response say "Please wait while I get the temperature for you" else if(response =~ /is the./i) #process their response say "Please wait while I check on that for you!" end end send_to_rosie(response) request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

requests prefixed by Computer or Rosie

listen_for /rosie|computer/i do |request| if (request == '') response = ask "Hi Wayne, what can I do for you?" send_to_rosie(response) else send_to_rosie(request) end request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

setting a device value

listenfor /(set|dim)(?: the) ([a-z]* ?[a-z']* [a-z']) [a-z] ([0-9,][0-9])/i do |action, device, value| if(action == 'set') say "Setting the #{device} to #{value}." else say "Dimming the #{device} to #{value}%." end send_to_rosie(action + ' ' + device + ' ' + value ) request_completed end

turning on or off a device or turning the thermostat up or down

listenfor /turn (on|off|up|down)(?: the)?([a-z] ?[a-z']* [a-z]_)/i do |action, name| say "Turning #{action} the #{name}." send-to_rosie('Turn ' + action + ' ' + name) request_completed end

leaving so turn down the downstairs thermostat

listen_for /(i'm|i am) leaving/i do say "Ok Wayne, see you later" send_to_rosie('away mode') request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

going to bed

listen_for /(good night|I'm going to bed|I am going to bed)/i do say "Good night Wayne, sweet dreams" send_to_rosie('good night') request_completed #always complete your request! Otherwise the phone will "spin" at the user! end listen_for /away mode/i do say "Ok Wayne, see you later" send_to_rosie('away mode') request_completed #always complete your request! Otherwise the phone will "spin" at the user! end listen_for /(what is|what's) the (upstairs|downstairs|temperature|inside) (in here|upstairs|downstairs|temperature|inside)/i do |ignore, what, where| say "Checking..." if ((what == 'downstairs') ||(where == 'downstairs')) result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'what is the temperature downstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else if ((what == 'upstairs') ||(where == 'upstairs')) result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'what is the temperature upstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'what is the temperature'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] end end request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

setting comfort more for heat or AC

listenfor /turn up the (ac|heat|temperature|thermostat|downstairs|upstairs)( upstairs| downstairs| heat| temperature| thermostat |ac)/i do |action,where| if(where == 'upstairs' || action == 'upstairs') say "Please wait while I set the upstairs thermostat to comfort mode" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'Turn up the heat upstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else if(where == 'downstairs' || action == 'downstairs' ) say "Please wait while I set the downstairs thermostat to comfort mode" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'Turn up the heat downstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else response = ask "I can turn up the heat for you, are you upstairs or downstairs?" if(response =~/upstairs/i) say "Please wait while I set the upstairs thermostat to comfort mode" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'Turn up the heat upstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else if(response =~ /downstairs/i) say "Please wait while I set the downstairs thermostat to comfort mode" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'Turn up the heat downstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else say "I am sorry, am an not sure where you are so I cannot turn up the heat" end end end end request_completed #always complete your request! Otherwise the phone will "spin" at the user! end listen_for /(cold|freezing|hot) in here/i do response = ask "I can turn up the heat for you, are you upstairs or downstairs?" if(response =~ /upstairs/i) say "Please wait while I set the upstairs thermostat to comfort mode" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'Turn up the heat upstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else if(response =~ /downstairs/i) say "Please wait while I set the downstairs thermostat to comfort mode" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => 'Turn up the heat downstairs'}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else say "I'm sorry, but I can't turn up the heat in the #{response}" end end request_completed #always complete your request! Otherwise the phone will "spin" at the user! end

send request to the rosie web service

def send_to_rosie(r) say "Working" result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => r}} rescue nil data = JSON.parse(result) rescue nil if (data["Say"] != '') response = ask data["Say"] result = RestClient.get 'http://192.168.1.30:6005/RosieRestServices/SiriClient', {:params => {:From => '[removed]', 'Body' => response}} rescue nil data = JSON.parse(result) rescue nil say data["Sms"] else say data["Sms"] end end

end`

GWayneC commented 11 years ago

BTW, thanks for all you help

On Tue, May 28, 2013 at 4:06 PM, Garfield Cousins < garfield.cousins@gmail.com> wrote:

OK, here is the main script file; the one with the rb extension is the one giving me trouble, the one with the .txt extension is my attempt to clean up and simplify. I apologize in advance for any I am still learning her, and I usually cleanup my code one I get everything working, I also what to thank you for your examples, I have been using othe one that pushed the cam pictures as an example for loading device info from a zwave web service.. but I haven;t got it to work yet.

On Tue, May 28, 2013 at 2:20 PM, Elvis notifications@github.com wrote:

It's had to troubleshoot without seeing your code. Perhaps you are missing a request_completed statement?

— Reply to this email directly or view it on GitHubhttps://github.com/plamoni/SiriProxy/issues/528#issuecomment-18569831 .

Garfield (Wayne) Cousins

“Vision without action is a daydream. Action without vision is a nightmare.” -Japanese Proverb

Garfield (Wayne) Cousins

“Vision without action is a daydream. Action without vision is a nightmare.” -Japanese Proverb

elvisimprsntr commented 11 years ago

I don't have time to re-write your code and it's well beyond the scope of an issue with siriproxy itself. I can offer two suggestions:

  1. use the siriproxy console to test your code and listen statements.
  2. post your question on stackoverflow.
GWayneC commented 11 years ago

Thanks, I did not expect you to re-write my code, I sent it in response to your last message, I am sorry if I mis-understood. I generally do not reach out for help until I am stumped and cannot find anything on the usual search engines.

As for troubleshooting in the console; I do see message indicating that the speech packet was recognized, however I still get a response from Apple's servers, also I have been carefully to complete the requests as suggested by "#always complete your request! Otherwise the phone will "spin" at the user!" And I use http://rubular.com/ to test my regular expressions before using them

Anyway thanks for you help, I will try stack overflow.

Regards.