ivona 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Gemfile.lock +17 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/ivona.gemspec +23 -0
- data/lib/ivona.rb +14 -0
- data/lib/ivona/additional_information.rb +54 -0
- data/lib/ivona/authorization.rb +18 -0
- data/lib/ivona/configuration.rb +5 -0
- data/lib/ivona/get_md5.rb +15 -0
- data/lib/ivona/pronunciation_rules.rb +58 -0
- data/lib/ivona/speech_generation.rb +60 -0
- data/lib/ivona/version.rb +3 -0
- metadata +92 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 bornfree
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Ruby client to talk to Ivona Speechcloud
|
data/ivona.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ivona/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ivona"
|
8
|
+
spec.version = Ivona::VERSION
|
9
|
+
spec.authors = ["bornfree"]
|
10
|
+
spec.email = ["harsha.xg@gmail.com"]
|
11
|
+
spec.description = %q{Ruby client to talk to ivona speech cloud / Repackaged from the speechcloud gem}
|
12
|
+
spec.summary = %q{Original credits: Sean Holden for the speechcloud gem}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
data/lib/ivona.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
BASE_URL = 'https://secure.ivona.com/api/saas/rest'
|
2
|
+
require 'digest/md5'
|
3
|
+
|
4
|
+
module Ivona
|
5
|
+
class << self; end
|
6
|
+
end
|
7
|
+
|
8
|
+
require 'ivona/version'
|
9
|
+
require 'ivona/authorization'
|
10
|
+
require 'ivona/speech_generation'
|
11
|
+
require 'ivona/pronunciation_rules'
|
12
|
+
require 'ivona/additional_information'
|
13
|
+
require 'ivona/get_md5'
|
14
|
+
require 'ivona/configuration'
|
@@ -0,0 +1,54 @@
|
|
1
|
+
module Ivona::AdditionalInfo
|
2
|
+
class << self
|
3
|
+
# Check the characters price for a specified speech parameters (text and voice pair)
|
4
|
+
def check_text_price(voice_id, text)
|
5
|
+
token = Ivona::Auth.get_token
|
6
|
+
md5 = Ivona::GetMd5.formula(token)
|
7
|
+
params = [ "token=#{token}",
|
8
|
+
"md5=#{md5}",
|
9
|
+
"text=#{text}",
|
10
|
+
"voiceId=#{voice_id}" ]
|
11
|
+
params = params.join('&')
|
12
|
+
HTTParty.get("#{BASE_URL}/textprice?#{params}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Show user TTS SaaS agreement data (this method will result in an error if there isn’t a SaaS agreement currently active for user)
|
16
|
+
def get_user_agreement_data
|
17
|
+
token = Ivona::Auth.get_token
|
18
|
+
md5 = Ivona::GetMd5.formula(token)
|
19
|
+
params = [ "token=#{token}",
|
20
|
+
"md5=#{md5}" ]
|
21
|
+
params = params.join('&')
|
22
|
+
HTTParty.get("#{BASE_URL}/agreementdata?#{params}")
|
23
|
+
end
|
24
|
+
|
25
|
+
# Get all available voices list
|
26
|
+
def list_voices
|
27
|
+
token = Ivona::Auth.get_token
|
28
|
+
md5 = Ivona::GetMd5.formula(token)
|
29
|
+
params = [ "token=#{token}",
|
30
|
+
"md5=#{md5}" ]
|
31
|
+
params = params.join('&')
|
32
|
+
HTTParty.get("#{BASE_URL}/voices?#{params}")
|
33
|
+
end
|
34
|
+
|
35
|
+
# Get single voice data
|
36
|
+
def get_voice_data( voice_id )
|
37
|
+
token = Ivona::Auth.get_token
|
38
|
+
md5 = Ivona::GetMd5.formula(token)
|
39
|
+
params = [ "token=#{token}",
|
40
|
+
"md5=#{md5}" ]
|
41
|
+
params = params.join('&')
|
42
|
+
HTTParty.get("#{BASE_URL}/voices/#{voice_id}?#{params}")
|
43
|
+
end
|
44
|
+
|
45
|
+
# Get all available codecs list
|
46
|
+
def list_codecs
|
47
|
+
token = Ivona::Auth.get_token
|
48
|
+
params = [ "token=#{token}",
|
49
|
+
"md5=#{Ivona::GetMd5.formula(token)}" ]
|
50
|
+
params = params.join('&')
|
51
|
+
HTTParty.get("#{BASE_URL}/codecs?#{params}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Ivona::Auth
|
4
|
+
class << self
|
5
|
+
# Make a request for a token
|
6
|
+
def get_token
|
7
|
+
email = Ivona::Config.email
|
8
|
+
options = { :body => "email=#{email}" }
|
9
|
+
HTTParty.post("#{BASE_URL}/tokens/", options)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Verify that token and md5 are legit. A response of 1 confirms that they are.
|
13
|
+
def check_token(token)
|
14
|
+
params = "token=#{token}&md5=#{Ivona::GetMd5.formula(token)}"
|
15
|
+
HTTParty.get("#{BASE_URL}/tokens?#{params}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Ivona::GetMd5
|
2
|
+
class << self
|
3
|
+
# Helper method to transform a string to MD5
|
4
|
+
def to_md5(a_string)
|
5
|
+
Digest::MD5.hexdigest(a_string)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Formula for md5 param is: md5( md5( api_key ) + token )
|
9
|
+
def formula(token)
|
10
|
+
api_key = Ivona::Config.api_key
|
11
|
+
api_key_as_md5 = to_md5( api_key )
|
12
|
+
to_md5( api_key_as_md5 + token )
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module Ivona::Pronunciation
|
2
|
+
class << self
|
3
|
+
# Get the data for all user’s pronunciation rules for selected language
|
4
|
+
# lang_id example: 'gb'
|
5
|
+
def list_pronunciation_rules( lang_id )
|
6
|
+
token = Ivona::Auth.get_token
|
7
|
+
md5 = Ivona::GetMd5.formula(token)
|
8
|
+
params = [ "token=#{token}",
|
9
|
+
"md5=#{md5}",
|
10
|
+
"langId=#{lang_id}" ]
|
11
|
+
params = params.join('&')
|
12
|
+
HTTParty.get("#{BASE_URL}/pronunciationrules?#{params}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# Add any number of pronunciation rules for selected language into user’s account
|
16
|
+
# lang_id example: 'en'
|
17
|
+
# stat example: 1 == case insensitive, 2 == case sensitive
|
18
|
+
# key (word to change) example: 'bcn'
|
19
|
+
# value (word it will change to) example: 'bacon'
|
20
|
+
def add_pronunciation_rule( lang_id, stat, key, value )
|
21
|
+
token = Ivona::Auth.get_token
|
22
|
+
md5 = Ivona::GetMd5.formula(token)
|
23
|
+
params = { token:token,
|
24
|
+
md5:md5,
|
25
|
+
langId:lang_id,
|
26
|
+
stat:stat,
|
27
|
+
key:key,
|
28
|
+
value:value }
|
29
|
+
HTTParty.post("#{BASE_URL}/pronunciationrules", {:body=>params})
|
30
|
+
end
|
31
|
+
|
32
|
+
# Modify any number of user’s pronunciation rules for selected language
|
33
|
+
# id is the rule identifier. Could be aquired by using the list_pronunciation_rules method
|
34
|
+
def modify_pronunciation_rule( id, lang_id, stat, key, value )
|
35
|
+
token = Ivona::Auth.get_token
|
36
|
+
md5 = Ivona::GetMd5.formula(token)
|
37
|
+
params = [ "token=#{token}",
|
38
|
+
"md5=#{md5}",
|
39
|
+
"langId=#{lang_id}",
|
40
|
+
"stat=#{stat}",
|
41
|
+
"key=#{key}",
|
42
|
+
"value=#{value}" ]
|
43
|
+
params = params.join('&')
|
44
|
+
HTTParty.put("#{BASE_URL}/pronunciationrules/#{id}?#{params}")
|
45
|
+
end
|
46
|
+
|
47
|
+
# Delete any number of user’s pronunciation rules for selected language.
|
48
|
+
def delete_pronunciation_rule( id, lang_id )
|
49
|
+
token = Ivona::Auth.get_token
|
50
|
+
md5 = Ivona::GetMd5.formula(token)
|
51
|
+
params = [ "token=#{token}",
|
52
|
+
"md5=#{md5}",
|
53
|
+
"langId=#{lang_id}" ]
|
54
|
+
params = params.join('&')
|
55
|
+
HTTParty.delete("#{BASE_URL}/pronunciationrules/#{id}?#{params}")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module Ivona::Speech
|
2
|
+
class << self
|
3
|
+
# Helper. Gathers params for the create_speech_file method defined below.
|
4
|
+
def get_speech_file_params(text, codec_id='mp3/22050' )
|
5
|
+
token = Ivona::Auth.get_token
|
6
|
+
md5 = Ivona::GetMd5.formula(token)
|
7
|
+
content_type = 'text/plain'
|
8
|
+
voice_id = Ivona::Config.voice_id
|
9
|
+
codec_id = Ivona::Config.codec_id
|
10
|
+
{ token: token,
|
11
|
+
md5: md5,
|
12
|
+
text: text,
|
13
|
+
contentType: content_type,
|
14
|
+
voiceId: voice_id,
|
15
|
+
codecId: codec_id }
|
16
|
+
end
|
17
|
+
|
18
|
+
# Get a url for a speech file generated from uploaded text.
|
19
|
+
def create_speech_file( text )
|
20
|
+
HTTParty.post("#{BASE_URL}/speechfiles", {:body=>get_speech_file_params( text )})
|
21
|
+
end
|
22
|
+
|
23
|
+
# Get a url for a speech file generated from uploaded text and for a text file with speech
|
24
|
+
# marks describing the positions of the text entities in a speech file.
|
25
|
+
def create_speech_file_with_marks( text )
|
26
|
+
HTTParty.post("#{BASE_URL}/speechfileswithmarks", {:body=>get_speech_file_params( text )})
|
27
|
+
end
|
28
|
+
|
29
|
+
# Delete a single speech file data
|
30
|
+
# Result: success (int: 0/1) – success (1) or failure (0) of the operation
|
31
|
+
def delete_speech_file( file_id )
|
32
|
+
token = Ivona::Auth.get_token
|
33
|
+
md5 = Ivona::GetMd5.formula(token)
|
34
|
+
params = [ "token=#{token}",
|
35
|
+
"md5=#{md5}" ]
|
36
|
+
params = params.join('&')
|
37
|
+
HTTParty.delete("#{BASE_URL}/speechfiles/#{file_id}?#{params}")
|
38
|
+
end
|
39
|
+
|
40
|
+
# Get a list of all active speech files for the current user
|
41
|
+
def list_speech_files
|
42
|
+
token = Ivona::Auth.get_token
|
43
|
+
md5 = Ivona::GetMd5.formula(token)
|
44
|
+
params = [ "token=#{token}",
|
45
|
+
"md5=#{md5}" ]
|
46
|
+
params = params.join('&')
|
47
|
+
HTTParty.get("#{BASE_URL}/speechfiles?#{params}")
|
48
|
+
end
|
49
|
+
|
50
|
+
# Getting data of single utterance
|
51
|
+
def get_speech_file_data( file_id )
|
52
|
+
token = Ivona::Auth.get_token
|
53
|
+
md5 = Ivona::GetMd5.formula(token)
|
54
|
+
params = [ "token=#{token}",
|
55
|
+
"md5=#{md5}" ]
|
56
|
+
params = params.join('&')
|
57
|
+
HTTParty.get("#{BASE_URL}/speechfiles/#{file_id}?#{params}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ivona
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- bornfree
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
prerelease: false
|
16
|
+
type: :development
|
17
|
+
name: bundler
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ! '>='
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '0'
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
prerelease: false
|
32
|
+
type: :development
|
33
|
+
name: rake
|
34
|
+
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
none: false
|
36
|
+
requirements:
|
37
|
+
- - ! '>='
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
requirement: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Ruby client to talk to ivona speech cloud / Repackaged from the speechcloud
|
47
|
+
gem
|
48
|
+
email:
|
49
|
+
- harsha.xg@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- Gemfile
|
55
|
+
- Gemfile.lock
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- ivona.gemspec
|
59
|
+
- lib/ivona.rb
|
60
|
+
- lib/ivona/additional_information.rb
|
61
|
+
- lib/ivona/authorization.rb
|
62
|
+
- lib/ivona/configuration.rb
|
63
|
+
- lib/ivona/get_md5.rb
|
64
|
+
- lib/ivona/pronunciation_rules.rb
|
65
|
+
- lib/ivona/speech_generation.rb
|
66
|
+
- lib/ivona/version.rb
|
67
|
+
homepage: ''
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
requirements: []
|
87
|
+
rubyforge_project:
|
88
|
+
rubygems_version: 1.8.25
|
89
|
+
signing_key:
|
90
|
+
specification_version: 3
|
91
|
+
summary: ! 'Original credits: Sean Holden for the speechcloud gem'
|
92
|
+
test_files: []
|