Permalink
Browse files

Make siriproxy itself into a gem, create a siriproxy binary, and rewo…

…rk directory structure and Gemfile to match (still not quite working right)
  • Loading branch information...
1 parent f97a576 commit dc52fb164b2548ad2dfc7d1901e0778202e478c6 @netpro2k netpro2k committed Nov 25, 2011
View
@@ -6,3 +6,6 @@ newkey.pem
newreq.pem
config.yml
Gemfile.lock
+*.gem
+.bundle
+pkg/*
View
@@ -1,8 +1,6 @@
source :gemcutter
-gem 'CFPropertyList'
-gem 'eventmachine'
-gem 'uuidtools'
+gemspec
# load plugins
require 'yaml'
View
@@ -1,8 +1,9 @@
require 'rake'
require 'rake/testtask'
+require "bundler/gem_tasks"
Rake::TestTask.new do |t|
t.libs << "test"
t.test_files = FileList['test/*.rb']
t.verbose = true
-end
+end
View
@@ -0,0 +1,25 @@
+#!/usr/bin/env ruby
+require 'pathname'
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
+ Pathname.new(__FILE__).realpath)
+
+require 'rubygems'
+require 'bundler'
+require 'bundler/setup'
+
+require 'yaml'
+require 'ostruct'
+
+require 'siriproxy'
+require 'siriproxy/connection'
+require 'siriproxy/connection/iphone'
+require 'siriproxy/connection/guzzoni'
+
+require 'siriproxy/plugin'
+require 'siriproxy/plugin_manager'
+
+APP_CONFIG = OpenStruct.new(YAML.load_file('config.yml'))
+LOG_LEVEL = APP_CONFIG.log_level.to_i
+proxy = SiriProxy.new()
+
+#that's it. :-)
View
@@ -1,49 +0,0 @@
-######
-# The idea behind this class is that you can call the different
-# methods to get different interpretations of a Siri object.
-# For instance, you can "unknown_intent" and it will check
-# to see if an object is a "Common#unknownIntent" response and
-# call the provided processor method with the appropriate info.
-# processor method signatures are provided in comments above each
-# method.
-#
-# each method will return "nil" if the object is not the valid
-# type. If it is, it will return the result of the processor.
-#####
-class InterpretSiri
- #Checks if the object is Guzzoni responding that it can't
- #determine the intent of the query
- #processor(object, connection, unknown_text)
- def unknown_intent(object, connection, processor)
- return false if object == nil
- return false if (!(object["properties"]["views"][0]["properties"]["dialogIdentifier"] == "Common#unknownIntent") rescue true)
-
- searchUtterance = object["properties"]["views"][1]["properties"]["commands"][0]["properties"]["commands"][0]["properties"]["utterance"]
- searchText = searchUtterance.split("^")[3]
- return processor.call(object, connection, searchText)
-
- return false
- end
-
- #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)
- return nil if object == nil
- return nil if (!(object["class"] == "SpeechRecognized") rescue true)
- phrase = ""
-
- 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"]
- }
- }
-
- phrase
- end
-
-end
File renamed without changes.
@@ -1,8 +1,6 @@
require 'eventmachine'
require 'zlib'
require 'pp'
-# require 'tweakSiri'
-require 'interpret_siri'
class String
def to_hex(seperator=" ")
@@ -31,6 +29,3 @@ def initialize()
end
end
end
-
-Interpret = InterpretSiri.new
-
@@ -1,4 +1,5 @@
require 'cfpropertylist'
+require 'siriproxy/interpret_siri'
class SiriProxy::Connection < EventMachine::Connection
include EventMachine::Protocols::LineText2
@@ -176,16 +177,16 @@ def prep_received_object(object)
object = received_object(object)
#block the rest of the session if a plugin claims ownership
- speech = Interpret.speech_recognized(object)
+ speech = SiriProxy::Interpret.speech_recognized(object)
if speech != nil
inject_object_to_output_stream(object)
block_rest_of_session if plugin_manager.process(speech)
return nil
end
- #object = new_obj if ((new_obj = Interpret.unknown_intent(object, self, plugin_manager.method(:unknown_command))) != false)
- #object = new_obj if ((new_obj = Interpret.speech_recognized(object, self, plugin_manager.method(:speech_recognized))) != false)
+ #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
@@ -196,4 +197,4 @@ def received_object(object)
object
end
-end
+end
@@ -0,0 +1,50 @@
+######
+# The idea behind this class is that you can call the different
+# methods to get different interpretations of a Siri object.
+# For instance, you can "unknown_intent" and it will check
+# to see if an object is a "Common#unknownIntent" response and
+# call the provided processor method with the appropriate info.
+# processor method signatures are provided in comments above each
+# method.
+#
+# each method will return "nil" if the object is not the valid
+# type. If it is, it will return the result of the processor.
+#####
+class SiriProxy::Interpret
+ class << self
+ #Checks if the object is Guzzoni responding that it can't
+ #determine the intent of the query
+ #processor(object, connection, unknown_text)
+ def unknown_intent(object, connection, processor)
+ return false if object == nil
+ return false if (!(object["properties"]["views"][0]["properties"]["dialogIdentifier"] == "Common#unknownIntent") rescue true)
+
+ searchUtterance = object["properties"]["views"][1]["properties"]["commands"][0]["properties"]["commands"][0]["properties"]["utterance"]
+ searchText = searchUtterance.split("^")[3]
+ return processor.call(object, connection, searchText)
+
+ return false
+ end
+
+ #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)
+ return nil if object == nil
+ return nil if (!(object["class"] == "SpeechRecognized") rescue true)
+ phrase = ""
+
+ 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"]
+ }
+ }
+
+ phrase
+ end
+ end
+end
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,3 @@
+module Siriproxy
+ VERSION = "0.0.1"
+end
Oops, something went wrong. Retry.

0 comments on commit dc52fb1

Please sign in to comment.