plamoni / SiriProxy

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

Show List #92

Open sbaumgarten opened 12 years ago

sbaumgarten commented 12 years ago

Hey, How can I show a list, like when you ask it what good restaurants are near you. I've tried to figure it out by logging all the data Guzzoni sends but I haven't found much.

Thanks

netpro2k commented 12 years ago

Siri is capable of displaying 2 types of lists. 1. option lists (like it shows when it wants you t select a phone number for a contact) and 2. location lists (like when doing a restaurant search).

We currently dont have API's exposed for either of these but we do plan to add them

sbaumgarten commented 12 years ago

Is there any way you can send me a beta copy of them?

netpro2k commented 12 years ago

All code we write is public on github. The dev branch will always represent the latest code. As of now, nobody has started work on selection lists.

sbaumgarten commented 12 years ago

I just got it working on my computer. Could I contribute to the repo.

netpro2k commented 12 years ago

we would like to add it as part of the "ask" method like:

ask "Which one?", options: ["Option 1", "Option 2"]

Would love to see your code, and if you have implemented it like the above, would love a pull request

davaxi commented 12 years ago

sbaumgarten, your object list is perfect. However I find it hard to understand how to retrieve the value selected. Could you help me with an example that would be perfect.

netpro2k commented 12 years ago

In the planned implementation it will be retrieved like so:

chosenOption = ask "Which one?", options: ["Option 1", "Option 2"]
sbaumgarten commented 12 years ago

@netpro2k I'm currently looking at the cora source to try and figure out how I would add it to the ask method. @davaxi and @netpro2k Currently I got it to work by adding the following code to siri_objects.rb:

class SiriDisambiguationList < SiriObject
 def initialize(speakableSelectionResponse="OK...", listenAfterSpeaking=true, speakableFinalDelimiter=", or ", speakableDelimiter=", ", items=[])
 super("DisambiguationList", "com.apple.ace.assistant")
 self.speakableSelectionResponse = speakableSelectionResponse
 self.listenAfterSpeaking = listenAfterSpeaking
 self.speakableFinalDelimiter = speakableFinalDelimiter
 self.speakableDelimiter = speakableDelimiter
 self.items = items
 end
 end
 add_property_to_class(SiriDisambiguationList, :speakableSelectionResponse)
 add_property_to_class(SiriDisambiguationList, :listenAfterSpeaking)
 add_property_to_class(SiriDisambiguationList, :speakableFinalDelimiter)
 add_property_to_class(SiriDisambiguationList, :speakableDelimiter)
 add_property_to_class(SiriDisambiguationList, :items)

 class SiriListItem < SiriObject
   def initialize(title="", speakableText="", commands=[])
     super("ListItem", "com.apple.ace.assistant")
     self.title = title
     self.speakableText = speakableText
     self.commands = commands
   end
 end
 add_property_to_class(SiriListItem, :title)
 add_property_to_class(SiriListItem, :speakableText)
 add_property_to_class(SiriListItem, :commands)

In the plugin I did

 listen_for /homework/i do
     add_views = SiriAddViews.new
     add_views.make_root(last_ref_id)
     disambiguation_list = SiriDisambiguationList.new
     disambiguation_list.items << SiriListItem.new("Math", "Math", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
        "properties"=> {
        "text"=>"For Math you have Math Homework #8 due tomorrow.", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )
     disambiguation_list.items << SiriListItem.new("English", "English", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
         "properties"=> {
        "text"=>"For English you have a Journal on today's in class discussion due tomorrow.", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )

     disambiguation_list.items << SiriListItem.new("Social Sciences", "Social Sciences", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
        "properties"=> {
        "text"=>"For Social Sciences you have to work on your final draft and project (if your doing one)!", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )

     disambiguation_list.items << SiriListItem.new("Science", "Science", [
     {
    "class"   =>"AddViews",
    "properties"   =>   {
       "temporary"        =>false,
       "dialogPhase"      =>"Summary",
       "scrollToTop"      =>false,
       "views"     =>      [
       {
        "class"=>"AssistantUtteranceView", 
        "properties"=> {
        "text"=>"For Science you have to keep working on your projects!", 
        "speakableText"=>"You have to keep working on your projects!", 
        "dialogIdentifier"=>"Misc#ident", 
        }, 
        "group"=>"com.apple.ace.assistant"
       }
       ]
       }, 
       "group"=>"com.apple.ace.assistant"
       }
       ]
       )
     utterance = SiriAssistantUtteranceView.new("Here are the classes you currently have assignments for. Which one would you like to look at in detail?")

     add_views.views << utterance
     add_views.views << disambiguation_list

     send_object add_views
     set_state :classes_available
     request_completed
   end
netpro2k commented 12 years ago

The code that goes into cora would obviously not deal with the concept of siri option lists, but rather just restrict what options are valid for the ask block. Then in SiriProxy's plugin ask would be overridden to handle displaying of the disambiguation list, but use cora's concept of restricting ask.

moieza commented 11 years ago

I try to make a plugin :)