Module: SpeechCloud::Pronunciation

Defined in:
lib/speechcloud/pronunciation_rules.rb

Class Method Summary collapse

Class Method Details

.add_pronunciation_rule(lang_id, stat, key, value) ⇒ Object

Add any number of pronunciation rules for selected language into user’s account lang_id example: ‘en’ stat example: 1 == case insensitive, 2 == case sensitive key (word to change) example: ‘bcn’ value (word it will change to) example: ‘bacon’



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/speechcloud/pronunciation_rules.rb', line 20

def add_pronunciation_rule( lang_id, stat, key, value )
  token  = SpeechCloud::Auth.get_token
  md5    = SpeechCloud::GetMd5.formula(token)
  params = {  token:token,
              md5:md5,
              langId:lang_id,
              stat:stat,
              key:key,
              value:value  }
  HTTParty.post("#{BASE_URL}/pronunciationrules", {:body=>params})
end

.delete_pronunciation_rule(id, lang_id) ⇒ Object

Delete any number of user’s pronunciation rules for selected language.



48
49
50
51
52
53
54
55
56
# File 'lib/speechcloud/pronunciation_rules.rb', line 48

def delete_pronunciation_rule( id, lang_id )
  token  = SpeechCloud::Auth.get_token
  md5    = SpeechCloud::GetMd5.formula(token)
  params = [  "token=#{token}",
              "md5=#{md5}",
              "langId=#{lang_id}"  ]
  params = params.join('&')
  HTTParty.delete("#{BASE_URL}/pronunciationrules/#{id}?#{params}")
end

.list_pronunciation_rules(lang_id) ⇒ Object

Get the data for all user’s pronunciation rules for selected language lang_id example: ‘gb’



5
6
7
8
9
10
11
12
13
# File 'lib/speechcloud/pronunciation_rules.rb', line 5

def list_pronunciation_rules( lang_id )
  token  = SpeechCloud::Auth.get_token
  md5    = SpeechCloud::GetMd5.formula(token)
  params = [  "token=#{token}",
              "md5=#{md5}",
              "langId=#{lang_id}"  ]
  params = params.join('&')
  HTTParty.get("#{BASE_URL}/pronunciationrules?#{params}")
end

.modify_pronunciation_rule(id, lang_id, stat, key, value) ⇒ Object

Modify any number of user’s pronunciation rules for selected language id is the rule identifier. Could be aquired by using the list_pronunciation_rules method



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/speechcloud/pronunciation_rules.rb', line 34

def modify_pronunciation_rule( id, lang_id, stat, key, value )
  token  = SpeechCloud::Auth.get_token
  md5    = SpeechCloud::GetMd5.formula(token)
  params = [  "token=#{token}",
              "md5=#{md5}",
              "langId=#{lang_id}",
              "stat=#{stat}",
              "key=#{key}",
              "value=#{value}"  ]
  params = params.join('&')
  HTTParty.put("#{BASE_URL}/pronunciationrules/#{id}?#{params}")
end