Sha256: b61c317eed45eb34626abb0b521125f272a06eb4bd4b222c02a9506f97f66e6b

Contents?: true

Size: 1.46 KB

Versions: 17

Compression:

Stored size: 1.46 KB

Contents

# encoding: utf-8

module Punchblock
  module Translator
    class Asterisk
      module Component
        class MRCPPrompt < Component
          include StopByRedirect
          include MRCPRecogPrompt

          private

          def validate
            raise OptionError, "The renderer #{renderer} is unsupported." unless renderer == 'unimrcp'
            raise OptionError, "The recognizer #{recognizer} is unsupported." unless recognizer == 'unimrcp'
            raise OptionError, 'An SSML document is required.' unless output_node.render_documents.count > 0
            raise OptionError, 'Only one document is allowed.' if output_node.render_documents.count > 1
            raise OptionError, 'A grammar is required.' unless input_node.grammars.count > 0

            super
          end

          def renderer
            (output_node.renderer || :unimrcp).to_s
          end

          def recognizer
            (input_node.recognizer || :unimrcp).to_s
          end

          def execute_unimrcp_app
            execute_app 'SynthAndRecog', render_doc, grammars
          end

          def render_doc
            d = output_node.render_documents.first
            if d.content_type
              d.value.to_doc.to_s
            else
              d.url
            end
          end

          def unimrcp_app_options
            super do |opts|
              opts[:vn] = output_node.voice if output_node.voice
            end
          end
        end
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
punchblock-2.7.5 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.7.3 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.7.2 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.7.1 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.7.0 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.6.0 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.5.3 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.5.2 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.5.1 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.5.0 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.4.2 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.4.0 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.3.1 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.3.0 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.2.2 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.2.1 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb
punchblock-2.2.0 lib/punchblock/translator/asterisk/component/mrcp_prompt.rb