Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for variable hear input #10

Open
blatyo opened this issue Jul 18, 2011 · 5 comments
Open

Add support for variable hear input #10

blatyo opened this issue Jul 18, 2011 · 5 comments

Comments

@blatyo
Copy link

blatyo commented Jul 18, 2011

It would be useful if what james could hear wasn't static. For example, imagine you could ask james a question:

    hear "What time will it be in (x)" => :time # What time will it be in 2 hours
    state :time do |time_delta|
        into do
          delta, delta_type = time_delta.split(' ') # => "2", "hours"
          time = delta.to_i.send(delta_type.to_sym).from_now # 2.hours.from_now
          "It will be #{time} in #{time_delta}"
        end
    end
@floere
Copy link
Owner

floere commented Jul 19, 2011

Hi Allen,

I think so too – however, at the moment you are limited to something like this:

hear "Calculate time" => :time

state :time do
  10.downto(1).each do |i|
    hear "What time will it be in #{i} hours?" => (->() do
      "It will be #{i.hours.from_now} in #{i} hours."
    end)
  end
end

For one of the immediate next versions, I will add into/exit block arguments, where the heard phrase is passed in.

Cheers

@KellyMahan
Copy link

Is it possible to have a drill down type of listening with a wildcard speech to text option? I know the evals shouldn't be used here, but its the simplest way to portray my idea. And I'm not familiar with james at all other than the example code. This is just an example usage that programmatically could be very useful

Example:

hear "What time will it be in" => :time

state :time do
    hear 2.words => :time_input
    state :time_input do |num, time_period|
        "It will be #{eval("num.#{time_period}.from_now")} in #{num} #{time_period}"
    end
end

@floere
Copy link
Owner

floere commented Oct 17, 2011

Hi Kelly,

I am afraid not (yet). Currently, the thing you can do is enumerate all possibilities, as with the example code in my last response. It enumerates all 10 options in a succinct way.

Does this help a bit?

Cheers,

@KellyMahan
Copy link

Sorry i should have phrased it a bit better. I was asking the question as in do you think it would be possible in the future with development based solely on the current tools? Or would it take different libraries to make that type of implementation possible.

@floere
Copy link
Owner

floere commented Oct 17, 2011

Thanks for the clarification!
No, I am afraid not. Using the current underlying library, I cannot arrive at variable hear input other that using static definitions.

However, with the possible arrival of Siri, and possible related libraries, it might be possible in the future. If yes, I am happy for any input (and notification that it is possible), and will update James' API accordingly.

Sidenote: It was once possible using the Carbon API, but as voice recognition was quite shaky, they didn't carry it over to Cocoa (that is my assumption based on trying it 7 years ago, when James was "born").

Cheers!

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

No branches or pull requests

3 participants