pollyspeech 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: f95748037162978f258c0d1f02ce55e0220d0c24
4
+ data.tar.gz: e803331facd91f61cac4731e1e7ccfda1723ba34
5
+ SHA512:
6
+ metadata.gz: 8ce56fecf9977e6932afafc0ef70475c518468e7f4aa1e18c3312960b0ded5119b9e944fa2f9e3ee00e2380b50b964aa38ae42037f1a3280f57bf3dbdd87647c
7
+ data.tar.gz: 9a81e27e8e10abe617ecc1e937e8025782cb116c7df006290b6281eb9bbe0f5e4fadf15721ec846fa0a1d2b01b23ec848ed21d688dd7d058cdabcc96bce7b73c
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: pollyspeech.rb
4
+
5
+
6
+ require 'aws-sdk'
7
+ require 'digest/md5'
8
+
9
+
10
+ class PollySpeech
11
+
12
+
13
+ def initialize(access_key: '', secret_key: '', region: 'us-east-1',
14
+ voice_id: 'Emma', cache_filepath: 'cache')
15
+
16
+ @polly = Aws::Polly::Client.new(region: region,
17
+ credentials: Aws::Credentials.new(access_key, secret_key))
18
+ @voice_id = voice_id
19
+ @cache_filepath = cache_filepath
20
+
21
+ end
22
+
23
+ def tts(text='', audiofile_out='/tmp/polly.ogg')
24
+
25
+ ext = File.extname(audiofile_out)
26
+ out_format = {'.ogg' => 'ogg_vorbis', '.mp3' => 'mp3'}[ext]
27
+
28
+ FileUtils.mkdir_p @cache_filepath
29
+
30
+ h = Digest::MD5.new << text
31
+ filename = File.join(@cache_filepath, h.to_s + ext)
32
+
33
+
34
+ # attempts to find the audio file from a local cache instead of
35
+ # making a relatively expensive request through the web API
36
+
37
+ if not File.exists? filename then
38
+
39
+ @polly.synthesize_speech(response_target: filename, text: text,
40
+ output_format: out_format, voice_id: @voice_id)
41
+
42
+ end
43
+
44
+ FileUtils.cp filename, audiofile_out
45
+
46
+ end
47
+
48
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pollyspeech
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
+ 8ixkARkWAmV1MB4XDTE3MDQyMjEwMjY0M1oXDTE4MDQyMjEwMjY0M1owSDESMBAG
16
+ A1UEAwwJZ2VtbWFzdGVyMR4wHAYKCZImiZPyLGQBGRYOamFtZXNyb2JlcnRzb24x
17
+ EjAQBgoJkiaJk/IsZAEZFgJldTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
+ ggEBAOlWJNNNmbsmxuwAT9pOHK6ldWdJ6H6i9hB3LuzKpJpCdxAvm8FRMYgFJ3ah
19
+ bwJda4S4wJDoiaTbjBCkza/Aq6tKJ0q1OVHiosWrwpcb9rzaCZHK4HAo3q48Og+r
20
+ cA/iqUiiiBx5qEu7XnVF6qv93FFIoldNpkdRTcoP8Gc3grTcKSnNCAJ9l+F8/CuL
21
+ AuFjBpGe7TRrp/89URO1PTIbSfDOKsUHTXMGG9pnWrGwXqfy0xIi8ulcpPWpItnu
22
+ 5oEmV1x2dfDIV2AI20/ui2Mb+MgzyiNrvxf+II8oiSUoQNmiO4jDMADzrl2hOxQW
23
+ Zh6GiGcRPFM09qeQbqxosWcRTxUCAwEAAaOBijCBhzAJBgNVHRMEAjAAMAsGA1Ud
24
+ DwQEAwIEsDAdBgNVHQ4EFgQUOdVqaS6McoXQnLC7XEkGpwfhzxIwJgYDVR0RBB8w
25
+ HYEbZ2VtbWFzdGVyQGphbWVzcm9iZXJ0c29uLmV1MCYGA1UdEgQfMB2BG2dlbW1h
26
+ c3RlckBqYW1lc3JvYmVydHNvbi5ldTANBgkqhkiG9w0BAQUFAAOCAQEAkfIGg9Jq
27
+ MnyF90fCg3SdbsqrMQA+WCnbaP6nmyUU/NTdIOs8BS1QQc7ENA8D8CtActL6MsGq
28
+ wZG011ccLobWCIyFMTptHohO1zMBXvzTTYBZyESJa0hrVlVscjL5Qx7VW1pvWPhD
29
+ UKuuFyyXOGo/k/ptJaQdMwnrIAR3/25yXfW+IsT3F9ZE/N7yc/PZF2v4/pPvT/Xi
30
+ AgHmyHqKhN3pdBiietojM1pAW5mf0GXedAgZ1W55eGjPFT1/Dwo4EG7JndNidu05
31
+ cC7uya6ydC5+WrZXqGY5rT56HCCwVLyA11XMKq5XhjGHhQ9YBwlIuPBCXkZ45f9x
32
+ FDdFDAj26Lp+8A==
33
+ -----END CERTIFICATE-----
34
+ date: 2017-04-22 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: aws-sdk
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.9'
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: 2.9.11
46
+ type: :runtime
47
+ prerelease: false
48
+ version_requirements: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '2.9'
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.9.11
56
+ description:
57
+ email: james@jamesrobertson.eu
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - lib/pollyspeech.rb
63
+ homepage: https://github.com/jrobertson/pollyspeech
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: A wrapper of the aws-sdk-polly gem which caches audio files locally. Defaults
87
+ to a British voice and OGG format.
88
+ test_files: []
@@ -0,0 +1,2 @@
1
+ ��#�dp��)J�bHavW/)5�j[F1��9�J�P��9�b9�3���ɠB� ��2�� ��_yQL�ꋓ&�xq���/D+�o�)��% ����o�i��­$��jg����u�?nj��t�;H�U+����,����q�xۤ��
2
+ ���C�Z�K_