speechcloud 0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
|
|
1
|
+
module SpeechCloud::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 = SpeechCloud::Auth.get_token
|
6
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
18
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
28
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
38
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
48
|
+
params = [ "token=#{token}",
|
49
|
+
"md5=#{SpeechCloud::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 SpeechCloud::Auth
|
4
|
+
class << self
|
5
|
+
# Make a request for a token
|
6
|
+
def get_token
|
7
|
+
email = SpeechCloud::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=#{SpeechCloud::GetMd5.formula(token)}"
|
15
|
+
HTTParty.get("#{BASE_URL}/tokens?#{params}")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SpeechCloud::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 = SpeechCloud::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 SpeechCloud::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 = SpeechCloud::Auth.get_token
|
7
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
22
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
36
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
50
|
+
md5 = SpeechCloud::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 SpeechCloud::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 = SpeechCloud::Auth.get_token
|
6
|
+
md5 = SpeechCloud::GetMd5.formula(token)
|
7
|
+
content_type = 'text/plain'
|
8
|
+
voice_id = SpeechCloud::Config.voice_id
|
9
|
+
codec_id = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
33
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
43
|
+
md5 = SpeechCloud::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 = SpeechCloud::Auth.get_token
|
53
|
+
md5 = SpeechCloud::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
CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- Sean Holden
|
@@ -38,6 +39,12 @@ extra_rdoc_files: []
|
|
38
39
|
|
39
40
|
files:
|
40
41
|
- lib/speechcloud.rb
|
42
|
+
- lib/speechcloud/additional_information.rb
|
43
|
+
- lib/speechcloud/authorization.rb
|
44
|
+
- lib/speechcloud/configuration.rb
|
45
|
+
- lib/speechcloud/get_md5.rb
|
46
|
+
- lib/speechcloud/pronunciation_rules.rb
|
47
|
+
- lib/speechcloud/speech_generation.rb
|
41
48
|
has_rdoc: true
|
42
49
|
homepage: http://rubygems.org/gems/speechcloud
|
43
50
|
licenses: []
|