adhearsion-asr 0.1.0 → 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c04b1a33ab083f07c27fcb249b183b1261fd24ff
4
- data.tar.gz: 30b74b8f7774084d0ba658b207330ba6070ea19e
3
+ metadata.gz: abddc20577b2b757df2aa327c9c1fe908841ecfb
4
+ data.tar.gz: 34e4855ccdd47a22dd7cffcd1d5fd21a12a86173
5
5
  SHA512:
6
- metadata.gz: 812e7c4fceaed9eccf44d9443ad42341b9f4c7bcc7b7b7a35b21e68813c316b7427de465fe01a42dbbc98474853bf0c9ef65e502a21c526e62b0a1d7c77cb3e9
7
- data.tar.gz: ca1aff66a38dc817b8929ed2229323736aedcb86c2d32778e8ed7832b0d5fb4baf31b2bb2a74a92b288df40d77dca35a77f9b04af9580aec5cde016648e7b6f6
6
+ metadata.gz: 2654531fda416beae8dcb47834aa6b27500c569d73d3c401fd7ac0b39aa03fdca69f3111f9e4a83e9a593e288daf90457438779bc7844304f0e524a75893953c
7
+ data.tar.gz: 450d71ea07dacbd19764260e465df19d5a5c7c0b1787a46066a78f065c5f893aac696a5c0af586edf5c6dabc3b6a5b936b59a4affeece93f3a3a0a9fe591910d
data/.travis.yml CHANGED
@@ -8,6 +8,6 @@ rvm:
8
8
  - ruby-head
9
9
  matrix:
10
10
  allow_failures:
11
- - rvm: jruby-19mode
11
+ - rvm: ruby-head
12
12
  notifications:
13
13
  irc: "irc.freenode.org#adhearsion"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # [develop](https://github.com/adhearsion/adhearsion-asr)
2
2
 
3
+ # [v1.0.0.beta](https://github.com/adhearsion/adhearsion-asr/compare/0.1.0...1.0.0.beta1) - [2013-08-27](https://rubygems.org/gems/adhearsion-asr/versions/1.0.0.beta1)
4
+ * Change: Controller methods are now included in all call controllers by default, but this is configurable
5
+ * Change: Default renderer/voice config is moved to Adhearsion core
6
+ * Change: `Result#response` is now `#utterance`
7
+ * Bugfix: DTMF input is now sanitized to remove spaces and `dtmf-` prefixes
8
+ * Bugfix: Function correctly on upcoming Adhearsion/Punchblock releases
9
+
3
10
  # [v0.1.0](https://github.com/adhearsion/adhearsion-asr/compare/6216ddb0a8b8c0ac5d1731ec154fe6d6abfea692...0.1.0) - [2013-05-07](https://rubygems.org/gems/adhearsion-asr/versions/0.1.0)
4
11
  * Feature: #ask and #menu from Adhearsion core
5
12
  * Mostly API compatible, with some very minor differences
data/Gemfile CHANGED
@@ -2,5 +2,4 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem 'adhearsion', github: 'adhearsion', branch: 'feature/rayo_prompt'
6
- gem 'punchblock', github: 'adhearsion/punchblock', branch: 'feature/new_rayo'
5
+ gem 'activesupport', '~> 3.0' if RUBY_VERSION == "1.9.2"
data/README.md CHANGED
@@ -9,31 +9,33 @@ Adds speech recognition support to Adhearsion as a plugin. Overrides `CallContro
9
9
 
10
10
  ## Install
11
11
 
12
- Add the following entries to your Adhearsion application's Gemfile:
12
+ Add the following entry to your Adhearsion application's Gemfile:
13
13
 
14
14
  ```ruby
15
15
  gem 'adhearsion-asr'
16
- gem 'adhearsion', github: 'adhearsion', branch: 'feature/rayo_prompt'
17
- gem 'punchblock', github: 'adhearsion/punchblock', branch: 'feature/new_rayo'
18
16
  ```
19
17
 
20
- The dependencies on Adhearsion and Punchblock from git are temporary and are required because this plugin uses functionality that is unreleased in those gems (mostly changes to keep up to date with the Rayo specification; they will be released once the Rayo specification has been advanced to Draft by the XSF).
21
-
22
18
  Be sure to check out the plugin config by running `rake config:show` and adjust to your requirements.
23
19
 
20
+ By default, this plugin overrides Adhearsion core's implementations of #ask and #menu with its own. To turn off this behaviour, set the `auto_include` option (see `rake config:show`) to false and include manually in controllers like so:
21
+
22
+ ```ruby
23
+ class MyController < Adhearsion::CallController
24
+ include AdhearsionASR::ControllerMethods
25
+ end
26
+ ```
27
+
24
28
  ## Examples
25
29
 
26
30
  ### Simple collection of 5 DTMF digits
27
31
 
28
32
  ```ruby
29
33
  class MyController < Adhearsion::CallController
30
- include AdhearsionASR::ControllerMethods
31
-
32
34
  def run
33
35
  result = ask limit: 5
34
36
  case result.status
35
37
  when :match
36
- speak "You entered #{result.response}"
38
+ speak "You entered #{result.utterance}"
37
39
  when :noinput
38
40
  speak "Hellooo? Anyone there?"
39
41
  when :nomatch
@@ -47,13 +49,11 @@ end
47
49
 
48
50
  ```ruby
49
51
  class MyController < Adhearsion::CallController
50
- include AdhearsionASR::ControllerMethods
51
-
52
52
  def run
53
53
  result = ask terminator: '#'
54
54
  case result.status
55
55
  when :match
56
- speak "You entered #{result.response}"
56
+ speak "You entered #{result.utterance}"
57
57
  when :noinput
58
58
  speak "Hellooo? Anyone there?"
59
59
  when :nomatch
@@ -67,8 +67,6 @@ end
67
67
 
68
68
  ```ruby
69
69
  class MyController < Adhearsion::CallController
70
- include AdhearsionASR::ControllerMethods
71
-
72
70
  def run
73
71
  grammar = RubySpeech::GRXML.draw root: 'main', language: 'en-us', mode: :voice do
74
72
  rule id: 'main', scope: 'public' do
@@ -82,7 +80,7 @@ class MyController < Adhearsion::CallController
82
80
  result = ask grammar: grammar, input_options: { mode: :speech }
83
81
  case result.status
84
82
  when :match
85
- speak "You said #{result.response}"
83
+ speak "You said #{result.utterance}"
86
84
  when :noinput
87
85
  speak "Hellooo? Anyone there?"
88
86
  when :nomatch
@@ -96,13 +94,11 @@ end
96
94
 
97
95
  ```ruby
98
96
  class MyController < Adhearsion::CallController
99
- include AdhearsionASR::ControllerMethods
100
-
101
97
  def run
102
98
  result = ask grammar_url: 'http://example.com/mygrammar.grxml', input_options: { mode: :speech }
103
99
  case result.status
104
100
  when :match
105
- speak "You said #{result.response}"
101
+ speak "You said #{result.utterance}"
106
102
  when :noinput
107
103
  speak "Hellooo? Anyone there?"
108
104
  when :nomatch
@@ -17,7 +17,10 @@ Gem::Specification.new do |s|
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_runtime_dependency %q<adhearsion>, ["~> 2.1"]
20
+ # s.add_runtime_dependency %q<adhearsion>, ["~> 2.4"]
21
+ # s.add_runtime_dependency %q<punchblock>, ["~> 2.0"]
22
+ s.add_runtime_dependency %q<adhearsion>, ["~> 2.4.0.beta3"]
23
+ s.add_runtime_dependency %q<punchblock>, ["~> 2.0.0.beta2"]
21
24
  s.add_runtime_dependency %q<ruby_speech>, ["~> 2.1"]
22
25
 
23
26
  s.add_development_dependency %q<bundler>, ["~> 1.0"]
@@ -23,19 +23,23 @@ module AdhearsionASR
23
23
  # @option options [String] :terminator Digit to terminate input
24
24
  # @option options [RubySpeech::GRXML::Grammar, Array<RubySpeech::GRXML::Grammar>] :grammar One of a collection of grammars to execute
25
25
  # @option options [String, Array<String>] :grammar_url One of a collection of URLs for grammars to execute
26
- # @option options [Hash] :input_options A hash of options passed directly to the Punchblock Input constructor
26
+ # @option options [Hash] :input_options A hash of options passed directly to the Punchblock Input constructor. See
27
27
  # @option options [Hash] :output_options A hash of options passed directly to the Punchblock Output constructor
28
28
  #
29
- # @return [Result] a result object from which the details of the response may be established
29
+ # @return [Result] a result object from which the details of the utterance may be established
30
30
  #
31
31
  # @see Output#play
32
- # @see Punchblock::Component::Input.new
33
- # @see Punchblock::Component::Output.new
32
+ # @see http://rdoc.info/gems/punchblock/Punchblock/Component/Input.new Punchblock::Component::Input.new
33
+ # @see http://rdoc.info/gems/punchblock/Punchblock/Component/Output.new Punchblock::Component::Output.new
34
34
  #
35
35
  def ask(*args)
36
36
  options = args.last.kind_of?(Hash) ? args.pop : {}
37
37
  prompts = args.flatten
38
38
 
39
+ if block_given?
40
+ logger.warn "You passed a block to #ask, but this functionality is not available in adhearsion-asr. If you're looking for the block validator functionality, you should avoid using it in favour of grammars, and it is deprecated in Adhearsion Core."
41
+ end
42
+
39
43
  options[:grammar] || options[:grammar_url] || options[:limit] || options[:terminator] || raise(ArgumentError, "You must specify at least one of limit, terminator or grammar")
40
44
 
41
45
  output_document = output_formatter.ssml_for_collection(prompts)
@@ -92,7 +96,7 @@ module AdhearsionASR
92
96
  # @option options [Hash] :input_options A hash of options passed directly to the Punchblock Input constructor
93
97
  # @option options [Hash] :output_options A hash of options passed directly to the Punchblock Output constructor
94
98
  #
95
- # @return [Result] a result object from which the details of the response may be established
99
+ # @return [Result] a result object from which the details of the utterance may be established
96
100
  #
97
101
  # @see Output#play
98
102
  # @see CallController#pass
@@ -63,7 +63,7 @@ module AdhearsionASR
63
63
 
64
64
  def handle_match(result)
65
65
  match = @matchers[result.interpretation.to_i]
66
- match.dispatch @context, result.response
66
+ match.dispatch @context, result.utterance
67
67
  throw :match
68
68
  end
69
69
 
@@ -93,11 +93,11 @@ module AdhearsionASR
93
93
  end
94
94
 
95
95
  Matcher = Struct.new(:payload, :keys) do
96
- def dispatch(controller, response)
96
+ def dispatch(controller, utterance)
97
97
  if payload.is_a?(Proc)
98
- controller.instance_exec response, &payload
98
+ controller.instance_exec utterance, &payload
99
99
  else
100
- controller.invoke payload, extension: response
100
+ controller.invoke payload, extension: utterance
101
101
  end
102
102
  end
103
103
 
@@ -1,11 +1,17 @@
1
1
  module AdhearsionASR
2
2
  class Plugin < Adhearsion::Plugin
3
3
  config :adhearsion_asr do
4
+ auto_include true, transform: Proc.new { |v| v == 'true' }, desc: "Enable or disable auto inclusion of overridden Adhearsion Core methods in all call controllers."
4
5
  min_confidence 0.5, desc: 'The default minimum confidence level used for all recognizer invocations.', transform: Proc.new { |v| v.to_f }
5
6
  timeout 5, desc: 'The default timeout (in seconds) used for all recognizer invocations.', transform: Proc.new { |v| v.to_i }
6
7
  recognizer nil, desc: 'The default recognizer used for all input. Set nil to use platform default.'
7
8
  input_language 'en-US', desc: 'The default language set on generated grammars. Set nil to use platform default.'
8
- renderer nil, desc: 'The default renderer used for all output. Set nil to use platform default.'
9
+ end
10
+
11
+ init do
12
+ if config[:auto_include]
13
+ ::Adhearsion::CallController.mixin ::AdhearsionASR::ControllerMethods
14
+ end
9
15
  end
10
16
  end
11
17
  end
@@ -5,7 +5,8 @@ module AdhearsionASR
5
5
  def initialize(output_document, grammars, options)
6
6
  output_options = {
7
7
  render_document: {value: output_document},
8
- renderer: Plugin.config.renderer
8
+ renderer: Adhearsion.config.platform.media.default_renderer,
9
+ voice: Adhearsion.config.platform.media.default_voice
9
10
  }.merge(options[:output_options] || {})
10
11
 
11
12
  input_options = {
@@ -36,14 +37,19 @@ module AdhearsionASR
36
37
  case reason
37
38
  when proc { |r| r.respond_to? :nlsml }
38
39
  result.status = :match
40
+ result.mode = reason.mode
39
41
  result.confidence = reason.confidence
40
- result.response = reason.utterance
42
+ result.utterance = reason.utterance
41
43
  result.interpretation = reason.interpretation
42
44
  result.nlsml = reason.nlsml
43
45
  when Punchblock::Event::Complete::Error
44
46
  raise Error, reason.details
45
- when Punchblock::Event::Complete::Reason
46
- result.status = reason.name
47
+ when Punchblock::Component::Input::Complete::NoMatch
48
+ result.status = :nomatch
49
+ when Punchblock::Component::Input::Complete::NoInput
50
+ result.status = :noinput
51
+ when Punchblock::Event::Complete::Hangup
52
+ result.status = :hangup
47
53
  else
48
54
  raise "Unknown completion reason received: #{reason}"
49
55
  end
@@ -1,11 +1,36 @@
1
1
  module AdhearsionASR
2
- Result = Struct.new(:status, :confidence, :response, :interpretation, :nlsml) do
2
+ Result = Struct.new(:status, :mode, :confidence, :utterance, :interpretation, :nlsml) do
3
3
  def to_s
4
- response
4
+ utterance
5
5
  end
6
6
 
7
7
  def inspect
8
- "#<#{self.class} status=#{status.inspect}, confidence=#{confidence.inspect}, response=#{response.inspect}, interpretation=#{interpretation.inspect}, nlsml=#{nlsml.inspect}>"
8
+ "#<#{self.class} status=#{status.inspect}, confidence=#{confidence.inspect}, utterance=#{utterance.inspect}, interpretation=#{interpretation.inspect}, nlsml=#{nlsml.inspect}>"
9
+ end
10
+
11
+ def utterance=(other)
12
+ self[:utterance] = mode == :dtmf ? parse_dtmf(other) : other
13
+ end
14
+
15
+ private
16
+
17
+ def parse_dtmf(dtmf)
18
+ return if dtmf.nil? || dtmf.empty?
19
+ dtmf.split(' ').inject '' do |final, digit|
20
+ final << parse_dtmf_digit(digit)
21
+ end
22
+ end
23
+
24
+ # @private
25
+ def parse_dtmf_digit(digit)
26
+ case tone = digit.split('-').last
27
+ when 'star'
28
+ '*'
29
+ when 'pound'
30
+ '#'
31
+ else
32
+ tone
33
+ end
9
34
  end
10
35
  end
11
36
  end
@@ -1,3 +1,3 @@
1
1
  module AdhearsionASR
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0.beta1"
3
3
  end
@@ -14,11 +14,11 @@ module AdhearsionASR
14
14
  subject { controller }
15
15
 
16
16
  before do
17
- mock call, write_command: true, id: call_id
17
+ double call, write_command: true, id: call_id
18
18
  end
19
19
 
20
- def expect_message_waiting_for_response(message, fail = false)
21
- expectation = controller.should_receive(:write_and_await_response).with message
20
+ def expect_message_waiting_for_utterance(message, fail = false)
21
+ expectation = controller.should_receive(:write_and_await_utterance).with message
22
22
  if fail
23
23
  expectation.and_raise fail
24
24
  else
@@ -26,8 +26,8 @@ module AdhearsionASR
26
26
  end
27
27
  end
28
28
 
29
- def expect_message_of_type_waiting_for_response(message)
30
- controller.should_receive(:write_and_await_response).with(message.class).and_return message
29
+ def expect_message_of_type_waiting_for_utterance(message)
30
+ controller.should_receive(:write_and_await_utterance).with(message.class).and_return message
31
31
  end
32
32
 
33
33
  def expect_component_execution(component, fail = false)
@@ -40,17 +40,17 @@ module AdhearsionASR
40
40
  expectation
41
41
  end
42
42
 
43
- def self.temp_config_value(key, value)
43
+ def self.temp_config_value(key, value, namespace = Plugin.config)
44
44
  before do
45
- @original_value = Plugin.config[key]
46
- Plugin.config[key] = value
45
+ @original_value = namespace[key]
46
+ namespace[key] = value
47
47
  end
48
48
 
49
- after { Plugin.config[key] = @original_value }
49
+ after { namespace[key] = @original_value }
50
50
  end
51
51
 
52
52
  before do
53
- controller.extend AdhearsionASR::ControllerMethods
53
+ Adhearsion::Plugin.init_plugins
54
54
  end
55
55
 
56
56
  let(:prompts) { ['http://example.com/nice-to-meet-you.mp3', 'http://example.com/press-some-buttons.mp3'] }
@@ -90,7 +90,7 @@ module AdhearsionASR
90
90
 
91
91
  let(:reason) { Punchblock::Component::Input::Complete::NoMatch.new }
92
92
 
93
- before { Punchblock::Component::Prompt.any_instance.stub complete_event: mock(reason: reason) }
93
+ before { Punchblock::Component::Prompt.any_instance.stub complete_event: double(reason: reason) }
94
94
 
95
95
  describe "#ask" do
96
96
  let :digit_limit_grammar do
@@ -121,6 +121,19 @@ module AdhearsionASR
121
121
 
122
122
  subject.ask prompts, limit: 5
123
123
  end
124
+
125
+ context "with a block passed" do
126
+ it "executes but logs a warning about the block validator" do
127
+ expect_component_execution expected_prompt
128
+ call.logger.should_receive(:warn).with(/validator/)
129
+ target = double
130
+ target.should_receive(:foo).never
131
+
132
+ subject.ask prompts, limit: 5 do |buffer|
133
+ target.foo
134
+ end
135
+ end
136
+ end
124
137
  end
125
138
 
126
139
  context "with a terminator" do
@@ -364,7 +377,7 @@ module AdhearsionASR
364
377
  expected_output_options.merge! renderer: 'something_else'
365
378
  end
366
379
 
367
- temp_config_value :renderer, 'something_else'
380
+ temp_config_value :default_renderer, 'something_else', Adhearsion.config.platform.media
368
381
 
369
382
  it "executes a Prompt with correct renderer" do
370
383
  expect_component_execution expected_prompt
@@ -373,6 +386,22 @@ module AdhearsionASR
373
386
  end
374
387
  end
375
388
 
389
+ context "with a different default output voice" do
390
+ let(:expected_grxml) { digit_limit_grammar }
391
+
392
+ before do
393
+ expected_output_options.merge! voice: 'something_else'
394
+ end
395
+
396
+ temp_config_value :default_voice, 'something_else', Adhearsion.config.platform.media
397
+
398
+ it "executes a Prompt with correct voice" do
399
+ expect_component_execution expected_prompt
400
+
401
+ subject.ask prompts, limit: 5
402
+ end
403
+ end
404
+
376
405
  context "with overridden input options" do
377
406
  let(:expected_grxml) { digit_limit_grammar }
378
407
 
@@ -401,14 +430,23 @@ module AdhearsionASR
401
430
  end
402
431
  end
403
432
 
404
- context "when a response is received" do
433
+ context "when a utterance is received" do
405
434
  let(:expected_grxml) { digit_limit_grammar }
406
435
 
436
+ before { expect_component_execution expected_prompt }
437
+
438
+ let(:result) { subject.ask prompts, limit: 5 }
439
+
407
440
  context "that is a match" do
441
+ let(:mode) { :dtmf }
442
+ let(:utterance) { '123' }
443
+
408
444
  let :nlsml do
445
+ utterance = self.utterance
446
+ mode = self.mode
409
447
  RubySpeech::NLSML.draw do
410
448
  interpretation confidence: 1 do
411
- input '123', mode: :dtmf
449
+ input utterance, mode: mode
412
450
  instance 'Foo'
413
451
  end
414
452
  end
@@ -416,39 +454,115 @@ module AdhearsionASR
416
454
 
417
455
  let(:reason) { Punchblock::Component::Input::Complete::Match.new nlsml: nlsml }
418
456
 
419
- it "returns :match status and the response" do
420
- expect_component_execution expected_prompt
421
-
422
- result = subject.ask prompts, limit: 5
457
+ it "returns :match status and the utterance" do
423
458
  result.status.should be :match
459
+ result.mode.should be :dtmf
424
460
  result.confidence.should == 1
425
- result.response.should == '123'
461
+ result.utterance.should == '123'
426
462
  result.interpretation.should == 'Foo'
427
- result.nlsml.should == nlsml
463
+ result.nlsml.should == nlsml.root
464
+ end
465
+
466
+ context "with speech input" do
467
+ let(:mode) { :speech }
468
+ let(:utterance) { 'Hello world' }
469
+
470
+ it "should not alter the utterance" do
471
+ result.utterance.should == 'Hello world'
472
+ end
473
+ end
474
+
475
+ context "with a single DTMF digit" do
476
+ context 'with dtmf- prefixes' do
477
+ let(:utterance) { 'dtmf-3' }
478
+
479
+ it "removes dtmf- previxes" do
480
+ result.utterance.should be == '3'
481
+ end
482
+ end
483
+
484
+ context 'with "star"' do
485
+ let(:utterance) { "dtmf-star" }
486
+
487
+ it "interprets as *" do
488
+ result.utterance.should be == '*'
489
+ end
490
+ end
491
+
492
+ context 'with "*"' do
493
+ let(:utterance) { '*' }
494
+
495
+ it "interprets as *" do
496
+ result.utterance.should be == '*'
497
+ end
498
+ end
499
+
500
+ context 'with "pound"' do
501
+ let(:utterance) { 'dtmf-pound' }
502
+
503
+ it "interprets pound as #" do
504
+ result.utterance.should be == '#'
505
+ end
506
+ end
507
+
508
+ context 'with "#"' do
509
+ let(:utterance) { '#' }
510
+
511
+ it "interprets # as #" do
512
+ result.utterance.should be == '#'
513
+ end
514
+ end
515
+
516
+ context 'without a dtmf- prefix' do
517
+ let(:utterance) { '1' }
518
+
519
+ it "correctly interprets the digits" do
520
+ result.utterance.should be == '1'
521
+ end
522
+ end
523
+
524
+ context 'with "star"' do
525
+ let(:utterance) { nil }
526
+
527
+ it "is nil when utterance is nil" do
528
+ result.utterance.should be == nil
529
+ end
530
+ end
531
+ end
532
+
533
+ context "with multiple digits separated by spaces" do
534
+ let(:utterance) { '1 dtmf-5 dtmf-star # 2' }
535
+
536
+ it "returns the digits without space separation" do
537
+ result.utterance.should be == '15*#2'
538
+ end
428
539
  end
429
540
  end
430
541
 
431
542
  context "that is a nomatch" do
432
543
  let(:reason) { Punchblock::Component::Input::Complete::NoMatch.new }
433
544
 
434
- it "returns :nomatch status and a nil response" do
435
- expect_component_execution expected_prompt
436
-
437
- result = subject.ask prompts, limit: 5
438
- result.status.should be :nomatch
439
- result.response.should be_nil
545
+ it "returns :nomatch status and a nil utterance" do
546
+ result.status.should eql(:nomatch)
547
+ result.utterance.should be_nil
440
548
  end
441
549
  end
442
550
 
443
551
  context "that is a noinput" do
444
552
  let(:reason) { Punchblock::Component::Input::Complete::NoInput.new }
445
553
 
446
- it "returns :noinput status and a nil response" do
447
- expect_component_execution expected_prompt
554
+ it "returns :noinput status and a nil utterance" do
555
+ result.status.should eql(:noinput)
556
+ result.utterance.should be_nil
557
+ end
558
+ end
448
559
 
449
- result = subject.ask prompts, limit: 5
450
- result.status.should be :noinput
451
- result.response.should be_nil
560
+ context "that is a hangup" do
561
+ let(:reason) { Punchblock::Event::Complete::Hangup.new }
562
+
563
+ it "returns :hangup status and a nil utterance" do
564
+ result.status.should eql(:hangup)
565
+ result.utterance.should be_nil
452
566
  end
453
567
  end
454
568
 
@@ -456,8 +570,6 @@ module AdhearsionASR
456
570
  let(:reason) { Punchblock::Event::Complete::Error.new details: 'foobar' }
457
571
 
458
572
  it "should raise an error with a message of 'foobar" do
459
- expect_component_execution expected_prompt
460
-
461
573
  expect { subject.ask prompts, limit: 5 }.to raise_error(AdhearsionASR::Error, /foobar/)
462
574
  end
463
575
  end
@@ -595,7 +707,7 @@ module AdhearsionASR
595
707
  expected_output_options.merge! renderer: 'something_else'
596
708
  end
597
709
 
598
- temp_config_value :renderer, 'something_else'
710
+ temp_config_value :default_renderer, 'something_else', Adhearsion.config.platform.media
599
711
 
600
712
  it "executes a Prompt with correct renderer" do
601
713
  expect_component_execution expected_prompt
@@ -606,6 +718,22 @@ module AdhearsionASR
606
718
  end
607
719
  end
608
720
 
721
+ context "with a different default output voice" do
722
+ before do
723
+ expected_output_options.merge! voice: 'something_else'
724
+ end
725
+
726
+ temp_config_value :default_voice, 'something_else', Adhearsion.config.platform.media
727
+
728
+ it "executes a Prompt with correct voice" do
729
+ expect_component_execution expected_prompt
730
+
731
+ subject.menu prompts do
732
+ match(1) {}
733
+ end
734
+ end
735
+ end
736
+
609
737
  context "with overridden input options" do
610
738
  before do
611
739
  expected_input_options.merge! inter_digit_timeout: 35000
@@ -686,8 +814,8 @@ module AdhearsionASR
686
814
  Punchblock::Component::Prompt.any_instance.stub(:complete_event) do
687
815
  invocation_count += 1
688
816
  case invocation_count
689
- when 1 then mock(reason: reason)
690
- when 2 then mock(reason: reason2)
817
+ when 1 then double(reason: reason)
818
+ when 2 then double(reason: reason2)
691
819
  else raise('Too many attempts')
692
820
  end
693
821
  end
@@ -742,8 +870,8 @@ module AdhearsionASR
742
870
  Punchblock::Component::Prompt.any_instance.stub(:complete_event) do
743
871
  invocation_count += 1
744
872
  case invocation_count
745
- when 1 then mock(reason: reason)
746
- when 2 then mock(reason: reason2)
873
+ when 1 then double(reason: reason)
874
+ when 2 then double(reason: reason2)
747
875
  else raise('Too many attempts')
748
876
  end
749
877
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: adhearsion-asr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Langfeld
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-07 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: adhearsion
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '2.1'
19
+ version: 2.4.0.beta3
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '2.1'
26
+ version: 2.4.0.beta3
27
+ - !ruby/object:Gem::Dependency
28
+ name: punchblock
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 2.0.0.beta2
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 2.0.0.beta2
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: ruby_speech
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -149,12 +163,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
149
163
  version: '0'
150
164
  required_rubygems_version: !ruby/object:Gem::Requirement
151
165
  requirements:
152
- - - '>='
166
+ - - '>'
153
167
  - !ruby/object:Gem::Version
154
- version: '0'
168
+ version: 1.3.1
155
169
  requirements: []
156
170
  rubyforge_project: adhearsion-asr
157
- rubygems_version: 2.0.0
171
+ rubygems_version: 2.0.3
158
172
  signing_key:
159
173
  specification_version: 4
160
174
  summary: Adds speech recognition support to Adhearsion as a plugin