voicerss2017e 0.1.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
+ SHA1:
3
+ metadata.gz: d1659dce4c62cc12f11a30e55aa0b4be4b978619
4
+ data.tar.gz: a0af6c4b796777982846911beae5c0475f527739
5
+ SHA512:
6
+ metadata.gz: ce4be7b1816ec6e848011436d65898138eb50644d707dbd383650cede06cbd19228fc7015b645a548fc95acd7b69e4684ae639d5f884153795596f6a3d9d7232
7
+ data.tar.gz: f6d958d06753be3cd0de159b41accd1928e056156ec793c20e181d85cca0b7dc019847bf1fdc4c4902d44c96d70b1ce98394d23baa1314aa8eebcd6fcfbd6bf3
@@ -0,0 +1,2 @@
1
+ E��3ab9�,��*h[��9�[�:PQ���B�+��kB,J��ȇ�i���U��1�hO�ä�.<pn�y8�̽)�d�9�O(c8�S�5܈;EMȟ��s(�F�=�$ ��(� ��Ѻ��9U�\�[y[�y[3���y�䯱^���)�Y�'��~��U�h�
2
+ ���J�b����Vy�T�"ax؊豙%���J>@� m����4m�d"֞���Y((��O���Rs��k�G}w�.W���ͷ
@@ -0,0 +1 @@
1
+ ��S�& Ή�p�����a��74��4+�Tp�C��/io��(ڊ������~����v����dv��+h��>���<T�,�O��v��F���+ȼ\|u �_�ޮ�B��0��f���e�=��}�z�"YOF�M6�kj ��a�U�� ��U;MQ�~���ڜ��+�#Н;�@�54 ����PN]�^��Z������\T�VC���jU�='� ���O�t>r�oenʁ?F��;`v��B;8�̒p�L�
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: voicerss2017e.rb
4
+
5
+ require 'digest/md5'
6
+ require 'voicerss2017'
7
+ require 'fileutils'
8
+
9
+ class VoiceRSSe
10
+
11
+ def initialize(api_key: nil, config: {}, cache_filepath: 'cache')
12
+
13
+ @config = ({
14
+ 'key' => api_key,
15
+ 'hl' => 'en-gb',
16
+ 'src' => 'hello world',
17
+ 'r' => '0',
18
+ 'c' => 'mp3',
19
+ 'f' => '44khz_16bit_stereo',
20
+ 'ssml' => 'false',
21
+ 'b64' => 'false'
22
+ }).merge config
23
+
24
+ @cache_filepath = cache_filepath
25
+
26
+ end
27
+
28
+ def tts(text='', audiofile_out='output.mp3')
29
+
30
+ FileUtils.mkdir_p @cache_filepath
31
+
32
+ h = Digest::MD5.new << text
33
+ filename = File.join(@cache_filepath, h.to_s + '.mp3')
34
+
35
+
36
+ # attempts to find the audio file from a local cache instead of
37
+ # making a relatively expensive request through the web API
38
+
39
+ if File.exists? filename then
40
+
41
+ FileUtils.cp filename, audiofile_out
42
+
43
+ else
44
+
45
+ voice = VoiceRSS.speech(@config.merge({'src' => text}))
46
+ File.write filename, voice['response']
47
+
48
+ end
49
+
50
+ end
51
+
52
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voicerss2017e
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - James Robertson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDljCCAn6gAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRIwEAYDVQQDDAlnZW1t
14
+ YXN0ZXIxHjAcBgoJkiaJk/IsZAEZFg5qYW1lc3JvYmVydHNvbjESMBAGCgmSJomT
15
+ 8ixkARkWAmV1MB4XDTE3MDQwODIwMjg0OVoXDTE4MDQwODIwMjg0OVowSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBANvjNKj/JXEkFOIx83T2BziQw+tPvISibUD8YpdZ5Rd5+nKktmxAjdcv945I
19
+ R2W/Z+/Kr+5XC6e/8+ZpdtUC+oxWyoGx+DD0QoUCYkpRZL3WJ6TUW1nHOeeVBgA9
20
+ dK1B1+tHr+kmx2OEF/BQ2/X3ldDm7Cu9xQKZyQeTtcbgfEKw4yOvD1j7MncJHUD/
21
+ RyWdhWyJFrL7fHfIPdu33aFx+CBVdvve6nwbbTU3YeUKphm14Lw4CWkrPZvdWZTC
22
+ tBS/c5QLb9/lP/I1NFUVZfyhol4lSYdE5BKMNDeVJw5nf5dJYrF5QtdL3UqjtvH1
23
+ o67lMl8vQjMoXe6JvKG3gKdCdScCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUIZwInPF/n8PP1AxO/VkJdopm/2YwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAQlcd1xIi
27
+ u+UaETEXRskJrY6xPmu8o8FAshTLt0D9Eh4pj2DZ4RdaZNWWjYBkfPQDdY3kqbui
28
+ CGvuB51bEri89LS6QuCS8AIIEdnYMgfotl6NQ3lDWjTVdXPZwFJU/sheASkwB5YA
29
+ +HEQ30x9H3d/sp/9RuBSfbVrcem/5ESVwzZDYEOoyKIEhcIewHF6YuwjPYw8qGZT
30
+ OBIuDehM3Y4gohh1LO8502U0tQzi27tb/SDJMVfWb4lBJ0C+dk1kIZHt5MWt1yBs
31
+ ZR3bSFAjKnhhFsdZcMOSH4lTQIASz189sEGy8XH4C2+ldZv6xdWZMdlHqFh0ZwDw
32
+ 9Ft4mkjor48shw==
33
+ -----END CERTIFICATE-----
34
+ date: 2017-04-08 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: voicerss2017
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '0.1'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 0.1.0
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '0.1'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 0.1.0
56
+ description:
57
+ email: james@jamesrobertson.eu
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/voicerss2017e.rb
63
+ homepage: https://github.com/jrobertson/voicerss2017e
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.6.8
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: An enhancement of the voicerss2017 gem by caching audio files locally to
87
+ reduce the number of requests to the web API.
88
+ test_files: []
Binary file