Class: Speechmatics::User::Jobs

Inherits:
API
  • Object
show all
Includes:
Configuration
Defined in:
lib/speechmatics/user/jobs.rb

Constant Summary

Constants included from Configuration

Configuration::DEFAULT_ADAPTER, Configuration::DEFAULT_ENDPOINT, Configuration::DEFAULT_USER_AGENT, Configuration::VALID_OPTIONS_KEYS

Constants included from Connection

Connection::ALLOWED_OPTIONS

Instance Attribute Summary

Attributes inherited from API

#current_options

Instance Method Summary collapse

Methods included from Configuration

#configure, extended, keys, #options, #reset!

Methods inherited from API

#apply_options, #args_to_options, #base_path, #delete, #get, #initialize, #list, #request, #update

Methods included from Connection

#connection, #merge_default_options

Constructor Details

This class inherits a constructor from Speechmatics::API

Instance Method Details

#attach_audio(params = {}) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/speechmatics/user/jobs.rb', line 30

def attach_audio(params={})
  file_path = params[:data_file]
  raise "No file specified for new job, please provide a :data_file value" unless file_path
  raise "No file exists at path '#{file_path}'" unless File.exists?(file_path)

  content_type = params[:content_type] || MimeMagic.by_path(file_path).to_s
  raise "No content type specified for file, please provide a :content_type value" unless content_type
  raise "Content type for file '#{file_path}' is not audio, it is '#{content_type}'." unless (content_type =~ /audio/)

  params[:data_file] = Faraday::UploadIO.new(file_path, content_type)
  params
end

#audio(params = {}) ⇒ Object



20
21
22
23
# File 'lib/speechmatics/user/jobs.rb', line 20

def audio(params={})
  self.current_options = current_options.merge(args_to_options(params))
  request(:get, "#{base_path}/audio")
end

#create(params = {}) ⇒ Object



9
10
11
12
13
# File 'lib/speechmatics/user/jobs.rb', line 9

def create(params={})
  attach_audio(params)
  set_mode(params)
  super
end

#set_mode(params = {}) ⇒ Object



25
26
27
28
# File 'lib/speechmatics/user/jobs.rb', line 25

def set_mode(params={})
  params[:model] ||= 'en-US'
  params
end

#transcript(params = {}) ⇒ Object



15
16
17
18
# File 'lib/speechmatics/user/jobs.rb', line 15

def transcript(params={})
  self.current_options = current_options.merge(args_to_options(params))
  request(:get, "#{base_path}/transcript")
end