cerecvoice2019 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 502921a90e9336a2f54bdaf92386543340b617898fce96a764612da096820e08
4
- data.tar.gz: d45935e2eaf8cd21454ca2b4e1891fb2049c35e8c58aeea0f8028f3f6b87fdd3
3
+ metadata.gz: 8093f56fcd132eeec3e8bdd115d7fc715f17284900a574ba12cec5f510fec43e
4
+ data.tar.gz: af61fd57e31813953dc1bcb82f90db34ea85a604eabc259e364a67af6b5b0f83
5
5
  SHA512:
6
- metadata.gz: 307db3b28bcd09cba841b912177d442fc6c51f05464604f09fde9be89e4ec05610c608d446fbd56f87e889cfc08c023f88dfb6a85faf02746d442123fb1efa5e
7
- data.tar.gz: 68926f9f1369cd0a067b12b23e33f39a661cbf12b3d2c4a9cedc8ef20169478d16039f059c9657b3c2c24b23dab3ecd030eea69c9dbdd90fef831386c11f4c82
6
+ metadata.gz: cfeec0ec409af56bf5e514dfeb5d7f7783c7a4be18d566288957b16367759ba34d3ddd7a72604ef84180878a17a63881a163e576f06f88696adf7935bef1b0cf
7
+ data.tar.gz: 3f9947420982b249b14237de8a984e87346c763483f9f462418a65ae7ea77afca0298172189014913dc47a52846d6f7f1c70dbd42f6e64a7f083cb1426e8006d
checksums.yaml.gz.sig CHANGED
Binary file
@@ -24,71 +24,71 @@ end
24
24
  class Cerecvoice2019
25
25
  include RXFHelperModule
26
26
  using ColouredText
27
-
28
- def initialize(accountid: nil, password: nil, voice: 'Heather', config: {},
29
- cache_filepath: 'cache',
27
+
28
+ def initialize(accountid: nil, password: nil, voice: 'Heather', config: {},
29
+ cache_filepath: 'cache',
30
30
  url: 'https://cerevoice.com/rest/rest_1_1.php', debug: false)
31
31
 
32
32
  @config = ({
33
- 'method' => 'speakExtended',
33
+ 'method' => 'speakExtended',
34
34
  'accountID' => accountid,
35
- 'password' => password,
35
+ 'password' => password,
36
36
  'voice' => voice,
37
37
  'audioFormat' => 'ogg',
38
38
  'sampleRate' => '48000',
39
39
  'metadata' => 'True',
40
40
  'audio3D' => 'True'
41
41
  }).merge config
42
-
42
+
43
43
  @url, @cache_filepath, @debug = url, cache_filepath, debug
44
44
 
45
45
  if @config['accountID'].nil? or @config['password'].nil? then
46
- raise Cerecvoice2019Error, 'invalid accountID or password'
47
- end
48
-
46
+ raise Cerecvoice2019Error, 'invalid accountID or password'
47
+ end
48
+
49
49
  end
50
50
 
51
51
  def tts(text='', voice=@config['voice'], out: 'output.' + @config['audioFormat'])
52
52
 
53
-
53
+
54
54
  audiofile_out = out
55
55
  @config['audioFormat'] = File.extname(out)[1..-1]
56
56
 
57
-
57
+
58
58
  raise Cerecvoice2019Error, 'text empty' if text.empty?
59
-
59
+
60
60
  FileUtils.mkdir_p @cache_filepath
61
-
61
+
62
62
  h = Digest::MD5.new << text + voice
63
63
  filename = File.join(@cache_filepath, h.to_s + '.'+ @config['audioFormat'])
64
-
65
-
66
- # attempts to find the audio file from a local cache instead of
64
+
65
+
66
+ # attempts to find the audio file from a local cache instead of
67
67
  # making a relatively expensive request through the web API
68
-
69
- if not File.exists? filename then
70
-
68
+
69
+ if not File.exist? filename then
70
+
71
71
  @config.merge!('text' => CGI.escape(text), 'voice' => voice)
72
72
  url = @url + '?' + @config.map {|x| x.join('=')}.join('&')
73
73
  puts ('url: ' + url.inspect).debug if @debug
74
74
  xml = URI.open(url).read
75
75
  puts ('xml: ' + xml.inspect).debug if @debug
76
-
76
+
77
77
  doc = Rexle.new xml
78
78
  audio_url = doc.root.text('fileUrl')
79
79
  puts ('audio_url: ' + audio_url.inspect).debug if @debug
80
-
81
-
80
+
81
+
82
82
  puts ('writing file: ' + filename.inspect).debug if @debug
83
-
83
+
84
84
  File.open(filename, "wb") do |saved_file|
85
85
  # the following "open" is provided by open-uri
86
86
  URI.open(audio_url) {|read_file| saved_file.write(read_file.read) }
87
- end
88
-
89
- end
87
+ end
90
88
 
91
- FileX.cp filename, audiofile_out
89
+ end
90
+
91
+ FileX.cp filename, audiofile_out
92
92
 
93
93
  end
94
94
 
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cerecvoice2019
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -36,7 +36,7 @@ cert_chain:
36
36
  hYpP9/k+i5ttHESknFpij4j0fsDhfh0l616jaUyXVegOL/79bnx043t+w7JvCsAL
37
37
  RrDC3HXoRpS5Xo/m99HQ8k9qx/h5l0gcDJA=
38
38
  -----END CERTIFICATE-----
39
- date: 2022-06-30 00:00:00.000000000 Z
39
+ date: 2023-01-20 00:00:00.000000000 Z
40
40
  dependencies:
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rxfhelper
@@ -47,7 +47,7 @@ dependencies:
47
47
  version: '1.6'
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
- version: 1.6.3
50
+ version: 1.6.4
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -57,7 +57,7 @@ dependencies:
57
57
  version: '1.6'
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: 1.6.3
60
+ version: 1.6.4
61
61
  description:
62
62
  email: digital.robertson@gmail.com
63
63
  executables: []
@@ -84,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  requirements: []
87
- rubygems_version: 3.3.7
87
+ rubygems_version: 3.4.4
88
88
  signing_key:
89
89
  specification_version: 4
90
90
  summary: 'Unofficial Cerevoice gem using their text-to-speech API. #tts'
metadata.gz.sig CHANGED
Binary file