class Punchblock::Translator::Asterisk::Component::MRCPNativePrompt

Private Instance Methods

audio_filename() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 43
def audio_filename
  path = if first_doc.ssml?
    first_doc.value.children.first.src
  else
    first_doc.value.first
  end.sub('file://', '')

  dir = File.dirname(path)
  basename = File.basename(path, '.*')
  if dir == '.'
    basename
  else
    File.join(dir, basename)
  end
end
execute_unimrcp_app() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 35
def execute_unimrcp_app
  execute_app 'MRCPRecog', grammars
end
first_doc() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 39
def first_doc
  output_node.render_documents.first
end
recognizer() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 31
def recognizer
  (input_node.recognizer || :unimrcp).to_s
end
renderer() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 27
def renderer
  (output_node.renderer || :asterisk).to_s
end
unimrcp_app_options() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 59
def unimrcp_app_options
  super do |opts|
    opts[:f] = audio_filename
  end
end
validate() click to toggle source
# File lib/punchblock/translator/asterisk/component/mrcp_native_prompt.rb, line 13
def validate
  raise OptionError, "The renderer #{renderer} is unsupported." unless renderer == 'asterisk'
  raise OptionError, "The recognizer #{recognizer} is unsupported." unless recognizer == 'unimrcp'

  raise OptionError, 'A 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, 'Only inline documents are allowed.' if first_doc.url
  raise OptionError, 'Only one audio file is allowed.' if first_doc.size > 1

  raise OptionError, 'A grammar is required.' unless input_node.grammars.count > 0

  super
end