cerecvoice2019 0.9.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f8b16313e9c5493cf1ef344f45d2d319e8da00de1929d678abd6e8398f77feb4
4
+ data.tar.gz: eb9314639424d0c8cf9fc7e1a407543eb461ee1b3c884e6be2b17d17a9e14c60
5
+ SHA512:
6
+ metadata.gz: f95ddec75d624123d6ac0b7e1f54abb5a540bf4ef27d0a0bf647bfb0dfeab6b28cb5faddbf788984969eb7eb844c74bf4a5c572215e9bb5354bc3846d0883e93
7
+ data.tar.gz: a637a448554ad42e8d43df2fbebb012699d2a40a15d878429f4d59a8773f0ca7ed41450af9d3b32320a36fbecdd8d7ae7e037cf0dd707690339721df1cc4a724
@@ -0,0 +1 @@
1
+ ���2�"�o���ρ�t�ڶ �s��c��^n���|$�� � �=�����`lS�[ ܅9�����|������< d6M��ۓ�0�]}�������C�������M�i�чH��b����xR���4���B�,�jZ WK��?��Ni��{�,�W?;��8�@��X��+yW����s������a1�,=L��,�\��ڀ�gui?�Y�%j[ �@���� ���)n��jlR_a=�T9����3Ρ�۲����$
@@ -0,0 +1,2 @@
1
+ �%0����A� ��o�7f1r��9 �������qgh�/�/΀v�8 +��=�
2
+ ����{�N��^ �-���[J�]!���FfpA�i+����&����?��9„"QJ+�@�F�ٿ ؛j�[u�j[=����Ҧn$[>as�Î�1E+�x���L�t�wYT�C�5V� Y��JıS���X�.Ι��n�� F�c�Ӹor���6X�T�V֗^׉��¢���,# -�?T\^��P�I#M�
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: cerecvoice2019.rb
4
+
5
+ require 'digest/md5'
6
+ require 'rxfhelper'
7
+
8
+
9
+ # English voices
10
+ # --------------
11
+ #
12
+ # England: Claire (Lancashire), Giles, Jack, Jess, Lauren, Sarah,
13
+ # Sue (Black Country), William
14
+ # Ireland: Caitlin
15
+ # Scotland: Dodo, Heather, Kirsty, Stuart
16
+ #
17
+
18
+ class Cerecvoice2019Error < Exception
19
+ end
20
+
21
+ class Cerecvoice2019
22
+ include RXFHelperModule
23
+ using ColouredText
24
+
25
+ def initialize(accountid: nil, password: nil, voice: 'Heather', config: {},
26
+ cache_filepath: 'cache',
27
+ url: 'https://cerevoice.com/rest/rest_1_1.php', debug: false)
28
+
29
+ @config = ({
30
+ 'method' => 'speakExtended',
31
+ 'accountID' => accountid,
32
+ 'password' => password,
33
+ 'voice' => voice,
34
+ 'audioFormat' => 'ogg',
35
+ 'sampleRate' => '48000',
36
+ 'metadata' => 'True',
37
+ 'audio3D' => 'True'
38
+ }).merge config
39
+
40
+ @url, @cache_filepath, @debug = url, cache_filepath, debug
41
+
42
+ if @config['accountID'].nil? or @config['password'].nil? then
43
+ raise Cerecvoice2019Error, 'invalid accountID or password'
44
+ end
45
+
46
+ end
47
+
48
+ def tts(text='', voice=@config['voice'], out: 'output.' + @config['audioFormat'])
49
+
50
+
51
+ audiofile_out =- out
52
+
53
+ raise Cerecvoice2019Error, 'text empty' if text.empty?
54
+
55
+ FileUtils.mkdir_p @cache_filepath
56
+
57
+ h = Digest::MD5.new << text + voice
58
+ filename = File.join(@cache_filepath, h.to_s + '.'+ @config['audioFormat'])
59
+
60
+
61
+ # attempts to find the audio file from a local cache instead of
62
+ # making a relatively expensive request through the web API
63
+
64
+ if not File.exists? filename then
65
+
66
+ @config.merge!('text' => CGI.escape(text), 'voice' => voice)
67
+ url = @url + '?' + @config.map {|x| x.join('=')}.join('&')
68
+ puts ('url: ' + url.inspect).debug if @debug
69
+ xml = open(url).read
70
+ puts ('xml: ' + xml.inspect).debug if @debug
71
+
72
+ doc = Rexle.new xml
73
+ audio_url = doc.root.text('fileUrl')
74
+ puts ('audio_url: ' + audio_url.inspect).debug if @debug
75
+
76
+
77
+ puts ('writing file: ' + filename.inspect).debug if @debug
78
+
79
+ File.open(filename, "wb") do |saved_file|
80
+ # the following "open" is provided by open-uri
81
+ open(audio_url) {|read_file| saved_file.write(read_file.read) }
82
+ end
83
+
84
+ end
85
+
86
+ FileUtils.cp filename, audiofile_out
87
+
88
+ end
89
+
90
+ end
91
+
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cerecvoice2019
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
+ YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTkxMDIwMTIzNzQ0WhcN
15
+ MjAxMDE5MTIzNzQ0WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
+ cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQCz6C+y
17
+ 6wFCCvUqbuB7H68hWtHH90U3OjRgghIkPe3UitLbcIg/57N08/UCrjdtTCdBUfhT
18
+ OuvAYHUuJDYYoc56Wvu6frwHPaslB1IEy7wwu5cpd4du2tPjIZ5O4FHm1b1wN/EA
19
+ +jVExkd7hdIpH/7VKGFl8dw97wQcQhv8VxcQK7UFDrRfZADeHVId/949aHOF7LAP
20
+ KKPFSq4Bh6+hSBMr++5rPanTdJp6OmI7NuNzZtONzUvP0qu6Mxq0HQUu5Bvpvjbf
21
+ uOxZHkHHkiJoRH9IUyb+07956f+kmMBsEHsXAmpLfSO8Trtzri+OPcKeKERWsOBc
22
+ tM4kHlFcTo43Yu5j34DhyMQtOAeCJftxYWMqz+03gIy51XDWC2ornLxfqUF5vVUm
23
+ foGlVCC760Y5dYVzl1P1reeVANYXHrPdigusowNNYqmWOg5XaCM82z5ahj5CpMoY
24
+ Fn17RQQUJgVLDPbmFCDhKRsLH8xGaU+0f5cF/8QuRNza96LRfuyN+jHjruUCAwEA
25
+ AaOBijCBhzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUB0SbvkWC
26
+ r1ZThGUpjZodSR8MMXowJgYDVR0RBB8wHYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0
27
+ c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1hc3RlckBqYW1lc3JvYmVydHNvbi5ldTAN
28
+ BgkqhkiG9w0BAQsFAAOCAYEAc897LK21e6dI8Q7jTEahOUSDM7XCSS96cUXYosJU
29
+ byF68UKvCImDUdtvBWdDSlTyqQ/AK/ZHt5TBg/hNXpQLS5Kpfz/hXuPOY7+ItyoV
30
+ GHUr9G3Lb8AuhuSuDZk7oODznIHokktnfNqS/IGZQfcwDStwZeutTSoUfW5UdsYC
31
+ UBJAZNy2cPFnKGJtvYkGbipnrF4jyquw5E95F8oQkYkkw4x9G+fGQJ+g1MNxMvgt
32
+ SeOcoucJeYt4nuCOG4W4QPGYt9+ZFSa5R4MZ+s8UmvkUv6BFa40kB1iw+YibnJI6
33
+ BibhJ5m6IgtYvP66oWw7PhFuJ96H/Xi8qnQTpdjeN/Yng6JEb9scYR63OZOTnEDo
34
+ vFjbnF4ZZvoUuA3XCIpfcn3tDjBT8MBa4SL4v5A2W5WuGLybKiHdfzuek4GoQrcC
35
+ otDtZWH5PiMo8YNpkjbLacTOBqdEE9sfYRWqxO2Au3Dh+IjGiH+4gvTKt9uFJ+rv
36
+ QNWsS+OhIQjXcOvPMxWb8r6p
37
+ -----END CERTIFICATE-----
38
+ date: 2019-10-20 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rxfhelper
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0.9'
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 0.9.4
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '0.9'
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.9.4
60
+ description:
61
+ email: james@jamesrobertson.eu
62
+ executables: []
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - lib/cerecvoice2019.rb
67
+ homepage: https://github.com/jrobertson/cerecvoice2019
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubygems_version: 3.0.3
87
+ signing_key:
88
+ specification_version: 4
89
+ summary: cerecvoice2019
90
+ test_files: []
Binary file