plamoni / SiriProxy

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

some words / combination of words result in "spinning" #566

Closed FiesoDuck closed 11 years ago

FiesoDuck commented 11 years ago

I am using the pre-installed image on my raspberry. The example is working fine. After tinkering around i got my own plugin up and running.

Now the weird part: Siri is only responding to some of my commands. I tried to rewrite my code several times with no succes. Even implementing some of my code into the example isnt working. I guess my formation or style of the code is messed up but i cant see why. I used nano, writing on my windows machine and ftp it to the pi and even "drag and drop" via putty.

For example (just a snippet):

  listen_for /wohnzimmer ausschalten/i do
    say "Licht im Wohnzimmer wurde ausgeschaltet!"
    request_completed
    system("~/raspberry-remote/./send 11111 1 0")
    system("~/raspberry-remote/./send 11111 4 0")
  end

  listen_for /wohnzimmer einschalten/i do
    say "Licht im Wohnzimmer wurde eingeschaltet!"
    request_completed
    system("~/raspberry-remote/./send 11111 1 1")
    system("~/raspberry-remote/./send 11111 4 1")
  end

Siri will only speak the first listen_for command. The console output of both commands are identical and Siri is recognizing both. The second one results in spinning.

elvisimprsntr commented 11 years ago

Try using siriproxy console [your launch options] and manually type the verbal commands. If the manual commands match, then the problem is Siri (Apple) is not responding with the exact text you have defined in your listen_for regex expression.

elvisimprsntr commented 11 years ago

Also try commenting out your system commands in the second listen_for and add simple puts statements. to help isolate between the say and your system lines.

FiesoDuck commented 11 years ago

Thank you for the quick reply!

This is my console output:

 >>wohnzimmer einschalten
=> Licht im Wohnzimmer wurde eingeschaltet!
sending systemCode[11111] unitCode[1] command[1]
sending systemCode[11111] unitCode[4] command[1]
 >>wohnzimmer ausschalten
=> Licht im Wohnzimmer wurde ausgeschaltet!
sending systemCode[11111] unitCode[1] command[0]
sending systemCode[11111] unitCode[4] command[0]

This is the server output:

[Info - Plugin Manager] Processing 'Wohnzimmer einschalten'
[Info - Plugin Manager] Processing plugin First
[Info - Plugin Manager] Matches (?i-mx:wohnzimmer einschalten)
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Licht im Wohnzimmer wurde eingeschaltet!
[Info - Plugin Manager] Sending Request Completed
sending systemCode[11111] unitCode[1] command[1]
sending systemCode[11111] unitCode[4] command[1]

[Info - Plugin Manager] Processing 'Wohnzimmer ausschalten'
[Info - Plugin Manager] Processing plugin First
[Info - Plugin Manager] Matches (?i-mx:wohnzimmer ausschalten)
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Licht im Wohnzimmer wurde ausgeschaltet!
[Info - Plugin Manager] Sending Request Completed
sending systemCode[11111] unitCode[1] command[0]
sending systemCode[11111] unitCode[4] command[0]

first command > no speaking first command > speaking

shouldn't both function the same? i am confused...

elvisimprsntr commented 11 years ago

Also try moving the request_completed after the system commands. If those do not work you may have to spawn a new thread for the system commands. Example:

listen_for /wohnzimmer einschalten/i do
     say "Licht im Wohnzimmer wurde eingeschaltet!"
     Thread.new {
         system("~/raspberry-remote/./send 11111 1 1")
         system("~/raspberry-remote/./send 11111 4 1")
         request_completed
     }
end

UPDATE: Fixed close bracket

FiesoDuck commented 11 years ago

Here is the testing plugin:

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

class SiriProxy::Plugin::First < SiriProxy::Plugin
listen_for /wohnzimmer einschalten/i do
     say "Licht im Wohnzimmer wurde eingeschaltet!"
     Thread.new {
         system("~/raspberry-remote/./send 11111 1 1")
         system("~/raspberry-remote/./send 11111 4 1")
         request_completed
     }
end

listen_for /wohnzimmer ausschalten/i do
     say "Licht im Wohnzimmer wurde ausgeschaltet!"
     Thread.new {
         system("~/raspberry-remote/./send 11111 1 0")
         system("~/raspberry-remote/./send 11111 4 0")
         request_completed
     }
end
end

Console Output (shortend):

[Info - Server] Starting SiriProxy on 0.0.0.0:443... [Info - Server] DNS server is not running yet, waiting 1 second... [Info - Server] DNS Server started, tainting 'guzzoni.apple.com' with 192.168.0.42 [Info - Server] SiriProxy up and running. [Info - Plugin Manager] Plugins loaded: First [Info - iPhone] Received Object: LoadAssistant [Info - iPhone] Received Object: SetRestrictions [Info - iPhone] Received Object: ClearContext [Info - iPhone] Received Object: SetSessionObjects [Info - iPhone] Received Object: StartSpeechRequest [Info - iPhone] Received Object: SetRequestOrigin [Info - Guzzoni] Received Object: AssistantLoaded [Info - iPhone] Received Object: SpeechPacket [Info - Guzzoni] Received Object: SetConnectionHeader [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: FinishSpeech [Info - Guzzoni] Received Object: SpeechRecognized [Info - Plugin Manager] Processing 'Wohnzimmer einschalten' [Info - Plugin Manager] Processing plugin First [Info - Plugin Manager] Matches (?i-mx:wohnzimmer einschalten) [Info - Plugin Manager] Applicable states: [Info - Plugin Manager] Current state: [Info - Plugin Manager] Matches, executing block [Info - Plugin Manager] Say: Licht im Wohnzimmer wurde eingeschaltet! sending systemCode[11111] unitCode[1] command[1] sending systemCode[11111] unitCode[4] command[1] [Info - Plugin Manager] Sending Request Completed [Info - iPhone] Received Object: SetRestrictions [Info - iPhone] Received Object: ClearContext [Info - iPhone] Received Object: StartSpeechRequest [Info - iPhone] Received Object: SpeechPacket [Info - iPhone] Received Object: FinishSpeech [Info - Guzzoni] Received Object: SpeechRecognized [Info - Plugin Manager] Processing 'Wohnzimmer ausschalten' [Info - Plugin Manager] Processing plugin First [Info - Plugin Manager] Matches (?i-mx:wohnzimmer ausschalten) [Info - Plugin Manager] Applicable states: [Info - Plugin Manager] Current state: [Info - Plugin Manager] Matches, executing block [Info - Plugin Manager] Say: Licht im Wohnzimmer wurde ausgeschaltet! sending systemCode[11111] unitCode[1] command[0] sending systemCode[11111] unitCode[4] command[0] [Info - Plugin Manager] Sending Request Completed

The system commands are executed well (like before) but the first command still results in spinning and Siri remains mute.

elvisimprsntr commented 11 years ago

I made a typo in my post, which I corrected. Change the close bracket

FiesoDuck commented 11 years ago

I noticed that too and corrected it before launching

elvisimprsntr commented 11 years ago

Here is the simplest plugin I have that works. https://github.com/elvisimprsntr/siriproxy-rpi/blob/master/lib/siriproxy-rpi.rb

The only differences I see are the initialize statements, indentation, blank lines, and require statements. For what you are trying to do in your plugin (at the moment), you do not need any require statements.

FiesoDuck commented 11 years ago

i cant get your plugin to work. it tries to speak and then crash.

[Info - Plugin Manager] Plugin Crashed: undefined method `generate_siri_utterance' for #<SiriProxy::PluginManager:0x1143948>
[Info - Guzzoni] Got invalid data (non-ACE protocol?), terminating the connection.

But theoretically speaking there is no obvious reason why my simple test plugin, that i had posted above, isnt working the way it should?

elvisimprsntr commented 11 years ago

Did you install my plugin following my instructions?
https://github.com/elvisimprsntr/siriproxy-rpi

Or simply paste my code into yours?

FiesoDuck commented 11 years ago

I followed the instructions, Siri does not recognize my english, i used the console and i got the right output. -> just fine I edited the listen_for command to a german word, then bundle, started the server and i got this:

[Info - Plugin Manager] Processing 'Test eins'
[Info - Plugin Manager] Processing plugin RPi
[Info - Plugin Manager] Matches (?i-mx:test eins)
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Your Raspberry Pi is 51.9°C or 125.4°F.
[Info - Plugin Manager] Plugin Crashed: undefined method `generate_siri_utterance' for #<SiriProxy::PluginManager:0x26d6708>
[Info - Guzzoni] Got invalid data (non-ACE protocol?), terminating the connection.

The strange thing: while i retried the instructions over and over again it worked once! i am quite sure that i did the same steps before. but i cant get it working again :(

I think i somehow messed up my pi. I try reinstalling the image and setting up the proxy again. Thank you for the awesome tool and the support!

elvisimprsntr commented 11 years ago

Someone else reported the same message with my plugin, but never reported back what they did to resolve it.
https://github.com/elvisimprsntr/siriproxy-rpi/issues/2

elvisimprsntr commented 11 years ago

Someone suggested the follow for a different repo: https://github.com/netpro2k/SiriProxy-Twitter/issues/2

Hopefully that will get my plugin working, but still does't resolve the original problem with yours.

FiesoDuck commented 11 years ago

Yes i found that, too. Its too bad this never got resolved. I reinstalled the image and followed the instructions at http://sourceforge.net/p/siriproxyrpi/wiki/Home/ .

My plugin still crashes, i didnt tested yours. As i asked before, is there any obvious reason why my test plugin isnt running? Because i am quite unsure with this stuff ;) . I think i tinker around with your plugin some more.

elvisimprsntr commented 11 years ago

I thought your plugin was just not getting siri to speak for one of your commands. Now it is crashing?

FiesoDuck commented 11 years ago

Excuse me. I did not crash, it is not speaking.

FiesoDuck commented 11 years ago

Maybe this could help to specifiy the problem:

I tried to implement the ask command.

I speak -> Siri gets the command (it says so in the logs) -> not speaking -> i cancle the request (pressing the spinning thingy) -> i try a diffrent command -> Siri interprets this as my answer to the question she should have asked before (and is speaking).

So for some reason Siri is stuck in the ask. Maybe this is helpful

elvisimprsntr commented 11 years ago

I have seen that behavior. If you cancel an ask request, siriproxy will resume at the same place when you invoke siri again. That is a different issue with siriproxy itself. My recollection is that if you dismiss siri on your device and invoke again it will exit the ask request.

Back to your original issue....

I know some Ruby files are very indentation dependent. For example, in the siriproxy config.yml file, the plugin entry lines need to be in very specific columns. I have also seen difficult to diagnose behavior when testing my plugins if I forget an end or } , but your plugin doesn't appear to be missing anything.

FiesoDuck commented 11 years ago

For some reason your plugin is working again after i deleted and reinstalled it (as stated above) once again. Siri is talking with my modified listen_for command for german dummys ;)

I changed the say commands and i implemented some code for switching lights on/off. Siri keeps talking. I am not 100% sure what i did diffrent this time but hey, it's working. Hopefully it stays that way.

Question is: What was causing this error? You think i am on to something or it is just some random mess?

elvisimprsntr commented 11 years ago

How are you editing/installing your files on your RPi? Using Windows and copying them over, or editing them directly on the RPi using something like nano?

FiesoDuck commented 11 years ago

Most of the times i use nano. What should i use or what should i especially avoid?

elvisimprsntr commented 11 years ago

The reason I ask is Windows text files require an extra CR-LF at the end of each line, which Linux doesn't require. Some Linux applications will throw errors if the extra characters are in the file. If you create the files directly in a Linux environment, then it will not be an issue. If you create files in a Windows environment and transfer them, the extra characters will be included depending what method you use to transfer the files.

http://www.editpadpro.com/tricklinebreak.html

If you created them all in the Linux environment, then it must be some other issue causing your plugin not to work as expected. What exactly, I don't know, but glad you got it working.

P.S. Thanks for the $

FiesoDuck commented 11 years ago

HA! Got the error right here:

talking:

  listen_for(/test eins/i) do
    get_temp
    request_completed       
  end
[Info - Plugin Manager] Processing 'Test eins'
[Info - Plugin Manager] Processing plugin RPi
[Info - Plugin Manager] Matches (?i-mx:test eins)
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Das ist ein Test!
[Info - Plugin Manager] Sending Request Completed`

non-talking

  listen_for(/wohnzimmer einschalten/i) do
    get_temp
    request_completed       
  end
[Info - Plugin Manager] Processing 'Wohnzimmer einschalten'
[Info - Plugin Manager] Processing plugin RPi
[Info - Plugin Manager] Matches (?i-mx:wohnzimmer einschalten)
[Info - Plugin Manager] Applicable states:
[Info - Plugin Manager] Current state:
[Info - Plugin Manager] Matches, executing block
[Info - Plugin Manager] Say: Das ist ein Test!
[Info - Plugin Manager] Sending Request Completed

I can switch back and forth and edit this 10 times and the result is the same every time. It depends on the listen_for. So it is the same error i got at the very first start of this thread. Isnt this weird?

//edit the "test eins" "wohnzimmer einschalten" is the only thing i am editing in the plugin

FiesoDuck commented 11 years ago

Siri does not like the german word "einschalten". I tested some commands that i did not specify in my plugin. Every word / commando that is not specified in my plugin gets the "I dont understand" answer from Siri. But if i say the word "einschalten" or "xy einschalten" Siri keeps spinning and remains silent. This has nothing todo with my plugin because its not even looking there and tries to process it.

[Info - Plugin Manager] Processing 'Schnuckelputz einschalten'
[Info - Plugin Manager] Processing plugin RPi
[Info - Plugin Manager] No matches for 'Schnuckelputz einschalten'

(funfact: schnuckelputz means something like "sweetheart")

Even a whole sentence with the word "einschalten" results in spinning. This is weird!

elvisimprsntr commented 11 years ago

I have read threads of others having issues with SiriProxy and German, but don't recall if there was a solution or what the root cause was.

FiesoDuck commented 11 years ago

I will investigate a bit more. For now i just stay away from the "bad word" Maybe this should be pointed out somewhere?

Thanks again!