Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

'StartCorrectedSpeechRequest' Handling #86

Open
hink opened this issue Nov 29, 2011 · 5 comments
Open

'StartCorrectedSpeechRequest' Handling #86

hink opened this issue Nov 29, 2011 · 5 comments

Comments

@hink
Copy link

hink commented Nov 29, 2011

It appears that 'StartCorrectedSpeechRequest' objects are not being handled by SiriProxy.

This object is sent when a user speaks a command, siri responds, and the original command is edited inline by scrolling up and touching on it to edit the command.

Things I've noticed:

  • the 'refId' becomes the 'interactionId' on the 'StartCorrectedSpeechRequest' object
  • The connection object when receiving the 'StartCorrectedSpeechRequest' appears to be guzzoni.
  • responses seem to reference the original requests 'refId' as its 'aceId'
@keyosk
Copy link

keyosk commented Dec 23, 2011

I've noticed that if you correct a speech item, it hangs and keeps your onscreen keyboard open, the only way for me to resolve it is to hold down the power button and immediately cancel.

@hink
Copy link
Author

hink commented Feb 2, 2012

:(

@r2pimimm
Copy link

r2pimimm commented Feb 8, 2013

I modified the code and now my siri proxy handled "StartCorrectedSpeechRequest".
I'm not sure whether all was as it should be, but I was working anyway.
You need to modified the files lib/siriproxy/interpret_siri.rb and and lib/siriproxy/connection.rb

@128keaton
Copy link

@r2pimimm A pull request or a download link would be nice...

@r2pimimm
Copy link

In lib/siriproxy/interpret_siri.rb

#Checks if the object is Guzzoni responding that it recognized
#speech. Sends "best interpretation" phrase to processor
#processor(object, connection, phrase)
def speech_recognized(object)
  #p object if !(object["class"] == "SpeechRecognized")
  #p object if !(object["class"] == "StartCorrectedSpeechRequest")
  return nil if object == nil
  return nil if (!(object["class"] == "SpeechRecognized") and !(object["class"] ==  "StartCorrectedSpeechRequest") rescue true)  ######This line is changed, added StartCorrectedSpeechRequest

  phrase = ""
  if(object["class"] == "StartCorrectedSpeechRequest") ######This line is added
    phrase << object["properties"]["utterance"]  ######This line is added
  else         ######This line is added
    object["properties"]["recognition"]["properties"]["phrases"].map { |phraseObj|
      phraseObj["properties"]["interpretations"].first["properties"]["tokens"].map { |token|
        tokenProps = token["properties"]
        phrase = phrase[0..-2] if tokenProps["removeSpaceBefore"]
        phrase << tokenProps["text"]
        phrase << " " if !tokenProps["removeSpaceAfter"]
     }
   }
 end  ######This line is added
  phrase
end

In lib/siriproxy/connection.rb

    if object["refId"] == self.last_ref_id && @block_rest_of_session
      puts "[Info - Dropping Object from Guzzoni] #{object["class"]}" if $LOG_LEVEL > 1
      pp object if $LOG_LEVEL > 3
      return nil
    end
    puts "[Info - #{self.name}] Received Object: #{object["class"]}" if $LOG_LEVEL == 1
    puts "[Info - #{self.name}] Received Object: #{object["class"]} (group: #{object["group"]})" if $LOG_LEVEL == 2
    puts "[Info - #{self.name}] Received Object: #{object["class"]} (group: #{object["group"]}, ref_id: #{object["refId"]}, ace_id: #{object["aceId"]})" if $LOG_LEVEL > 2
    pp object if $LOG_LEVEL > 3

    #keeping this for filters
    new_obj = received_object(object)
    if new_obj == nil
      puts "[Info - Dropping Object from #{self.name}] #{object["class"]}" if $LOG_LEVEL > 1
      pp object if $LOG_LEVEL > 3
      return nil
    end

    #block the rest of the session if a plugin claims ownership
    speech = SiriProxy::Interpret.speech_recognized(object)
    if speech != nil
      if(object["class"] == "StartCorrectedSpeechRequest")  #######This line is added
        object["refId"]=object["aceId"] #######This line is added
        #pp object #######This line is added
      end #######This line is added
      inject_object_to_output_stream(object)
      @block_rest_of_session if plugin_manager.process(speech)
      return nil
    end


    #object = new_obj if ((new_obj = SiriProxy::Interpret.unknown_intent(object, self, plugin_manager.method(:unknown_command))) != false)
    #object = new_obj if ((new_obj = SiriProxy::Interpret.speech_recognized(object, self, plugin_manager.method(:speech_recognized))) != false)

    object
  end

I don't remember, maybe I changed more lines, but this work.
Now I've noticed that, if you correct your speech then only proxy handle it.
There must be more what needed to change or add.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants