Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge adhearsion-asr in to core to replace the original
#menu
and `…
…#ask` methods Adds support for speech recognition and moves recognition logic out of Adhearsion, pushing it to a (speech-)recognizer.
- Loading branch information
1 parent
dcfff14
commit 8df5e14
Showing
41 changed files
with
1,534 additions
and
2,293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
lib/adhearsion/call_controller/input/ask_grammar_builder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# encoding: utf-8 | ||
|
||
module Adhearsion | ||
class CallController | ||
module Input | ||
class AskGrammarBuilder | ||
def initialize(options) | ||
@options = options | ||
end | ||
|
||
def grammars | ||
@grammars ||= build_grammars | ||
end | ||
|
||
private | ||
|
||
def build_grammars | ||
grammars = [] | ||
|
||
grammars.concat [@options[:grammar]].flatten.compact.map { |val| {value: val} } if @options[:grammar] | ||
grammars.concat [@options[:grammar_url]].flatten.compact.map { |val| {url: val} } if @options[:grammar_url] | ||
|
||
if grammars.empty? | ||
limit = @options[:limit] | ||
grammar = RubySpeech::GRXML.draw mode: :dtmf, root: 'digits' do | ||
rule id: 'digits', scope: 'public' do | ||
item repeat: "0-#{limit}" do | ||
one_of do | ||
0.upto(9) { |d| item { d.to_s } } | ||
item { "#" } | ||
item { "*" } | ||
end | ||
end | ||
end | ||
end | ||
grammars << {value: grammar} | ||
end | ||
|
||
grammars | ||
end | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.