module Ivona::Speech

Public Class Methods

create_speech_file( text ) click to toggle source

Get a url for a speech file generated from uploaded text.

# File lib/ivona/speech_generation.rb, line 19
def create_speech_file( text )
  HTTParty.post("#{BASE_URL}/speechfiles", {:body=>get_speech_file_params( text )})
end
create_speech_file_with_marks( text ) click to toggle source

Get a url for a speech file generated from uploaded text and for a text file with speech marks describing the positions of the text entities in a speech file.

# File lib/ivona/speech_generation.rb, line 25
def create_speech_file_with_marks( text )
  HTTParty.post("#{BASE_URL}/speechfileswithmarks", {:body=>get_speech_file_params( text )})
end
delete_speech_file( file_id ) click to toggle source

Delete a single speech file data Result: success (int: 0/1) – success (1) or failure (0) of the operation

# File lib/ivona/speech_generation.rb, line 31
def delete_speech_file( file_id )
  token  = Ivona::Auth.get_token
  md5    = Ivona::GetMd5.formula(token)
  params = [  "token=#{token}",
              "md5=#{md5}"  ]
  params = params.join('&')
  HTTParty.delete("#{BASE_URL}/speechfiles/#{file_id}?#{params}")
end
get_speech_file_data( file_id ) click to toggle source

Getting data of single utterance

# File lib/ivona/speech_generation.rb, line 51
def get_speech_file_data( file_id )
  token  = Ivona::Auth.get_token
  md5    = Ivona::GetMd5.formula(token)
  params = [  "token=#{token}",
              "md5=#{md5}"  ]
  params = params.join('&')
  HTTParty.get("#{BASE_URL}/speechfiles/#{file_id}?#{params}")
end
get_speech_file_params(text, codec_id='mp3/22050' ) click to toggle source

Helper. Gathers params for the create_speech_file method defined below.

# File lib/ivona/speech_generation.rb, line 4
def get_speech_file_params(text, codec_id='mp3/22050' )
  token        = Ivona::Auth.get_token
  md5          = Ivona::GetMd5.formula(token)
  content_type = 'text/plain'
  voice_id     = Ivona::Config.voice_id
  codec_id     = Ivona::Config.codec_id
  {  token:       token,
     md5:         md5,
     text:        text,
     contentType: content_type,
     voiceId:     voice_id,
     codecId:     codec_id  }
end
list_speech_files() click to toggle source

Get a list of all active speech files for the current user

# File lib/ivona/speech_generation.rb, line 41
def list_speech_files
  token  = Ivona::Auth.get_token
  md5    = Ivona::GetMd5.formula(token)
  params = [  "token=#{token}",
              "md5=#{md5}"  ]
  params = params.join('&')
  HTTParty.get("#{BASE_URL}/speechfiles?#{params}")
end