dejan-espeak-ruby 0.1.2 → 0.2.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.
- data/README.rdoc +15 -10
- data/VERSION.yml +2 -2
- data/lib/espeak-ruby.rb +24 -6
- metadata +1 -1
data/README.rdoc
CHANGED
|
@@ -2,24 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
espeak-ruby is small Ruby API for utilizing 'espeak' and 'lame' to create Text-To-Speech mp3 files.
|
|
4
4
|
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* eSpeak is a compact open source software speech synthesizer for English and other languages, for Linux and Windows.
|
|
6
|
+
* LAME is a high quality MPEG Audio Layer III (MP3) encoder licensed under the LGPL.
|
|
7
|
+
|
|
8
|
+
== Example
|
|
7
9
|
|
|
8
|
-
== examples
|
|
9
10
|
require 'rubygems'
|
|
10
11
|
require 'espeak-ruby'
|
|
11
12
|
|
|
12
13
|
include ESpeak
|
|
13
14
|
|
|
14
15
|
espeak("Hello World")
|
|
15
|
-
espeak("Guten Tag", :
|
|
16
|
+
espeak("Guten Tag", :v => "de")
|
|
17
|
+
|
|
18
|
+
== Requirements
|
|
19
|
+
|
|
20
|
+
* Linux or Windows (I failed in trying to compile espeak on Mac)
|
|
21
|
+
* http://espeak.sourceforge.net
|
|
22
|
+
* http://lame.sourceforge.net/index.php
|
|
16
23
|
|
|
17
|
-
==
|
|
24
|
+
== Related
|
|
18
25
|
|
|
19
|
-
*
|
|
20
|
-
* espeak http://espeak.sourceforge.net
|
|
21
|
-
* lame http://lame.sourceforge.net/index.php
|
|
26
|
+
* http://github.com/dejan/espeak-http - Micro web app for Text-To-Speech conversion via HTTP powered by Ruby, Sinatra, lame, espeak and espeak-ruby
|
|
22
27
|
|
|
23
|
-
==
|
|
28
|
+
== Credits
|
|
24
29
|
|
|
25
|
-
Dejan Simic ~ http://rors.org
|
|
30
|
+
Author: Dejan Simic ~ http://rors.org
|
data/VERSION.yml
CHANGED
data/lib/espeak-ruby.rb
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
-
require '
|
|
2
|
+
require 'digest/sha1'
|
|
3
3
|
|
|
4
4
|
module ESpeak
|
|
5
|
-
def espeak(text, opts = {})
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
def espeak(text, opts = {})
|
|
8
7
|
opts.symbolize_keys!
|
|
9
|
-
options
|
|
8
|
+
options = {
|
|
9
|
+
:v => 'en', # use voice file of this name from espeak-data/voices
|
|
10
|
+
:p => 50, # pitch adjustment, 0 to 99
|
|
11
|
+
:s => 170 # speed in words per minute, 80 to 370
|
|
12
|
+
}.merge(opts)
|
|
13
|
+
|
|
10
14
|
sanitized_text = text.gsub(/(!|\?|"|`|\\)/, ' ')
|
|
15
|
+
filename = Digest::SHA1.hexdigest(options.to_s)
|
|
11
16
|
|
|
12
|
-
if system(%$espeak "#{sanitized_text}" --stdout -v#{options[:lang]} -p#{options[:pitch]} -s#{options[:speed]} | lame -V2 - #{
|
|
13
|
-
|
|
17
|
+
if system(%$espeak "#{sanitized_text}" --stdout -v#{options[:lang]} -p#{options[:pitch]} -s#{options[:speed]} | lame -V2 - #{filename}$)
|
|
18
|
+
filename
|
|
14
19
|
else
|
|
15
20
|
raise "Error while running espeak. You don't seem to have espeak or lame installed ..."
|
|
16
21
|
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def symbolize_keys
|
|
27
|
+
inject({}) do |options, (key, value)|
|
|
28
|
+
options[(key.to_sym rescue key) || key] = value
|
|
29
|
+
options
|
|
30
|
+
end
|
|
31
|
+
end
|
|
17
32
|
|
|
33
|
+
def symbolize_keys!
|
|
34
|
+
self.replace(self.symbolize_keys)
|
|
18
35
|
end
|
|
36
|
+
|
|
19
37
|
end
|