Class: Speechpad::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/speechpad/client.rb

Instance Method Summary collapse

Methods included from Request

#get, #post

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
# File 'lib/speechpad/client.rb', line 6

def initialize(options={})
  @access_key = options[:access_key]
  @secret_key = options[:secret_key]
  @speechpad_url =  options[:url] || 'https://www.speechpad.com/'
end

Instance Method Details

#add_audio_url(url, visible_filename = url, transcribe = true, options = {}) ⇒ Mash

Add a new audio to the user’s account from a URL, should be a file.

Examples:

Add a url of a file to be transcribed

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.add_audio_url('https://www.speechpad.com/is_a.mp3')

Parameters:

  • url (String)

    A valid URL to the file to be downloaded

  • visible_filename (String) (defaults to: url)

    The filename to display to user, defaults to url if blank

  • transcribe (Boolean) (defaults to: true)

    'false' - set 'true' to initiate transcription

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



25
26
27
28
29
# File 'lib/speechpad/client.rb', line 25

def add_audio_url(url, visible_filename=url,  transcribe=true, options={})
  params = build_params({'operation' => 'add_audio_url', 'method' => 'post', 'visible_filename' => visible_filename,
                        'url' => url, 'transcribe' => transcribe}.merge(options))
  get(params)
end

#add_media_url(url, transcribe = true, options = {}) ⇒ Mash

Add a new media to the user’s account from a URL, like Youtube.

Examples:

Add a media url to a file to be transcribed

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.add_media_url('http://www.youtube.com/watch?v=meiU6TxysCg')

Parameters:

  • url (String)

    A valid URL to the file to be downloaded

  • transcribe (Boolean) (defaults to: true)

    'false' - set 'true' to initiate transcription

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



40
41
42
43
# File 'lib/speechpad/client.rb', line 40

def add_media_url(url, transcribe=true, options={})
  params = build_params({'operation' => 'add_media_url', 'method' => 'post', 'url' => url, 'transcribe' => transcribe}.merge(options))
  get(params)
end

#get_machine_transcription(audio_id, options = {}) ⇒ Mash

Return the machine transcription status of one or more audio files.

Examples:

Get the machine transcription of the audio file

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.get_machine_transcription(1234)

Parameters:

  • audio_id (String)

    The ID of the audio file

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



66
67
68
69
# File 'lib/speechpad/client.rb', line 66

def get_machine_transcription(audio_id, options={})
  params = build_params({'operation' => 'get_machine_transcription', 'method' => 'get', 'audio_id' => audio_id}.merge(options))
  get(params)
end

#get_transcription(audio_id, options = {}) ⇒ Mash

Return the transcription status of one or more audio files.

Examples:

Get the transcription of the audio file

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.get_transcription(1234)

Parameters:

  • audio_id (String)

    The ID of the audio file

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



53
54
55
56
# File 'lib/speechpad/client.rb', line 53

def get_transcription(audio_id, options={})
  params = build_params({'operation' => 'get_transcription', 'method' => 'get', 'audio_id' => audio_id}.merge(options))
  get(params)
end

#machine_transcription_status(audio_id, options = {}) ⇒ Mash

Return the machine transcription status of one or more audio files.

Examples:

Get the machine transcription status of the audio file

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.machine_transcription_status(1234)

Parameters:

  • audio_id (String)

    The ID of the audio file

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



80
81
82
83
# File 'lib/speechpad/client.rb', line 80

def machine_transcription_status(audio_id, options={})
  params = build_params({'operation' => 'machine_transcription_status', 'method' => 'get', 'audio_id' => audio_id}.merge(options))
  get(params)
end

#test(options = {}) ⇒ Mash

A test call for the Speechpad API (only works on dev).

Examples:

Get the transcription status of the audio file

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.test

Parameters:

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



105
106
107
108
# File 'lib/speechpad/client.rb', line 105

def test(options={})
  params = build_params({'operation' => 'test', 'value' => '123', 'method' => 'get'}.merge(options))
  get(params, options)
end

#transcription_status(audio_id, options = {}) ⇒ Mash

Return the transcription status of one or more audio files.

Examples:

Get the transcription status of the audio file

s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
s.transcription_status(1234)

Parameters:

  • audio_id (String)

    The ID of the audio file

  • options (Hash) (defaults to: {})

    Optional Params

Returns:

  • (Mash)

    Mashify body with ERROR_STRING and Response



93
94
95
96
# File 'lib/speechpad/client.rb', line 93

def transcription_status(audio_id, options={})
  params = build_params({'operation' => 'transcription_status', 'method' => 'get', 'audio_id' => audio_id}.merge(options))
  get(params)
end