lib/adhearsion-asr/prompt_builder.rb in adhearsion-asr-1.0.1 vs lib/adhearsion-asr/prompt_builder.rb in adhearsion-asr-1.1.0

- old
+ new

@@ -1,16 +1,10 @@ require 'adhearsion-asr/result' module AdhearsionASR class PromptBuilder def initialize(output_document, grammars, options) - output_options = { - render_document: {value: output_document}, - renderer: Adhearsion.config.platform.media.default_renderer, - voice: Adhearsion.config.platform.media.default_voice - }.merge(options[:output_options] || {}) - input_options = { mode: :dtmf, initial_timeout: (options[:timeout] || Plugin.config.timeout) * 1000, inter_digit_timeout: (options[:timeout] || Plugin.config.timeout) * 1000, max_silence: (options[:timeout] || Plugin.config.timeout) * 1000, @@ -19,10 +13,20 @@ recognizer: Plugin.config.recognizer, language: Plugin.config.input_language, terminator: options[:terminator] }.merge(options[:input_options] || {}) - @prompt = Punchblock::Component::Prompt.new output_options, input_options, barge_in: options.has_key?(:interruptible) ? options[:interruptible] : true + @prompt = if output_document + output_options = { + render_document: {value: output_document}, + renderer: Adhearsion.config.platform.media.default_renderer, + voice: Adhearsion.config.platform.media.default_voice + }.merge(options[:output_options] || {}) + + Punchblock::Component::Prompt.new output_options, input_options, barge_in: options.has_key?(:interruptible) ? options[:interruptible] : true + else + Punchblock::Component::Input.new input_options + end end def execute(controller) controller.execute_component_and_await_completion @prompt