espeak-ruby 1.0.0 → 1.0.1

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.

Potentially problematic release.


This version of espeak-ruby might be problematic. Click here for more details.

data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  espeak-ruby
2
2
  ===========
3
3
 
4
- espeak-ruby is a small Ruby API for utilizing [espeak](http://espeak.sourceforge.net) and [lame](http://lame.sourceforge.net/) to create Text-To-Speech mp3 files.
4
+ espeak-ruby is a small Ruby API for utilizing [espeak](http://espeak.sourceforge.net) and [lame](http://lame.sourceforge.net/) to create Text-To-Speech mp3 files. It can also just speak (without saving).
5
5
  See the [live demo](http://rors.org/demos/espeak-ruby).
6
6
 
7
7
  Install
@@ -13,17 +13,31 @@ Add _espeak-ruby_ to Gemfile
13
13
  gem "espeak-ruby", require: "espeak"
14
14
  ```
15
15
 
16
- Example
17
- -------
16
+ Examples
17
+ --------
18
+
19
+ First you need to include ESpeak module to access espeak API
20
+
21
+ ```ruby
22
+ include ESpeak
23
+ ```
24
+
25
+ Then use it like this:
18
26
 
19
27
  ```ruby
20
28
  # Speaks "YO!"
21
- speech = ESpeak::Speech.new("YO!")
29
+ speech = Speech.new("YO!")
22
30
  speech.speak # invokes espeak
23
31
 
24
32
  # Creates hello-de.mp3 file
25
- speech = ESpeak::Speech.new("Hallo Welt", voice: "de")
33
+ speech = Speech.new("Hallo Welt", voice: "de")
26
34
  speech.save("hello-de.mp3") # invokes espeak + lame
35
+
36
+ # Lists voices
37
+ Voice.all.map { |v| v.language } # ["af", "bs", "ca", "cs", "cy", "da", "de", "el", "en", "en-sc", "en-uk", "en-uk-north", "en-uk-rp", "en-uk-wmids", "en-us", "en-wi", "eo", "es", "es-la", "fi", "fr", "fr-be", "grc", "hi", "hr", "hu", "hy", "hy", "id", "is", "it", "jbo", "ka", "kn", "ku", "la", "lv", "mk", "ml", "nci", "nl", "no", "pap", "pl", "pt", "pt-pt", "ro", "ru", "sk", "sq", "sr", "sv", "sw", "ta", "tr", "vi", "zh", "zh-yue"]
38
+
39
+ # Find particular voice
40
+ Voice.find_by_language('en') #<ESpeak::Voice:0x007fe1d3806be8 @language="en", @name="default", @gender="M", @file="default">
27
41
  ```
28
42
 
29
43
  Features
@@ -40,7 +54,7 @@ Currently only subset of espeak features is supported.
40
54
  These are default values, and they can be easily overridden:
41
55
 
42
56
  ```ruby
43
- ESpeak::Speech.new("Zdravo svete", voice: "sr", pitch: 90, speed: 200).speak
57
+ Speech.new("Zdravo svete", voice: "sr", pitch: 90, speed: 200).speak
44
58
  ```
45
59
 
46
60
  Requirements
data/lib/espeak.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  module ESpeak
2
2
  autoload :Speech, 'espeak/speech'
3
+ autoload :Voice, 'espeak/voice'
3
4
  end
data/lib/espeak/speech.rb CHANGED
@@ -59,9 +59,6 @@ module ESpeak
59
59
  "lame -V2 - #{filename} #{'--quiet' if options[:quiet] == true}"
60
60
  end
61
61
 
62
- def execute_system_command(filename, options)
63
- end
64
-
65
62
  def symbolize_keys(hash)
66
63
  hash.inject({}) do |options, (key, value)|
67
64
  options[(key.to_sym rescue key) || key] = value
@@ -0,0 +1,29 @@
1
+ require 'csv'
2
+
3
+ module ESpeak
4
+ class Voice
5
+ attr_reader :language, :name, :gender, :file
6
+ def initialize(attributes)
7
+ @language = attributes[:language]
8
+ @name = attributes[:name]
9
+ @gender = attributes[:gender]
10
+ @file = attributes[:file]
11
+ end
12
+
13
+ def self.all
14
+ voices = []
15
+ CSV.parse(espeak_voices, headers: :first_row, col_sep: ' ') do |row|
16
+ voices << Voice.new(language: row[1], gender: row[2], name: row[3], file: row[4] )
17
+ end
18
+ voices
19
+ end
20
+
21
+ def self.find_by_language(lang)
22
+ all.find { |v| v.language == lang.to_s }
23
+ end
24
+
25
+ def self.espeak_voices
26
+ `espeak --voices`
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ require "test_helper"
2
+
3
+ class VoiceTest < Test::Unit::TestCase
4
+ include ESpeak
5
+
6
+ def setup
7
+ voices_file = File.read("test/fixtures/voices.txt")
8
+ Voice.expects(:espeak_voices).returns(voices_file)
9
+ end
10
+
11
+ def test_all
12
+ all_voices = Voice.all
13
+ assert all_voices.size > 0
14
+ assert %w(M F).include?(all_voices.first.gender)
15
+ end
16
+
17
+ def test_find_by_language
18
+ voice = Voice.find_by_language('en')
19
+ assert_equal 'en', voice.language
20
+ end
21
+ end
@@ -0,0 +1,60 @@
1
+ Pty Language Age/Gender VoiceName File Other Langs
2
+ 5 af M afrikaans af
3
+ 5 bs M bosnian bs
4
+ 5 ca M catalan ca
5
+ 5 cs M czech cs
6
+ 5 cy M welsh-test cy
7
+ 5 da M danish da
8
+ 5 de M german de
9
+ 5 el M greek el
10
+ 5 en M default default
11
+ 5 en-sc M en-scottish en/en-sc (en 4)
12
+ 2 en-uk M english en/en (en 2)
13
+ 5 en-uk-north M lancashire en/en-n (en-uk 3)
14
+ 5 en-uk-rp M english_rp en/en-rp (en-uk 4)
15
+ 5 en-uk-wmids M english_wmids en/en-wm
16
+ 2 en-us M english-us en/en-us (en-r 5)(en 3)
17
+ 5 en-wi M en-westindies en/en-wi (en-uk 4)
18
+ 5 eo M esperanto eo
19
+ 5 es M spanish es
20
+ 5 es-la M spanish-latin-american es-la (es-mx 6)
21
+ 5 fi M finnish fi
22
+ 5 fr M french fr
23
+ 5 fr-be M french (Belgium) fr-be
24
+ 5 grc M greek-ancient test/grc
25
+ 5 hi M hindi-test hi
26
+ 5 hr M croatian hr (hbs 5)
27
+ 5 hu M hungarian hu
28
+ 5 hy M armenian hy
29
+ 5 hy M armenian-west hy-west
30
+ 5 id M indonesian-test id
31
+ 5 is M icelandic-test is
32
+ 5 it M italian it
33
+ 5 jbo lojban test/jbo
34
+ 5 ka georgian-test ka
35
+ 5 kn kannada kn
36
+ 5 ku M kurdish ku
37
+ 5 la M latin la
38
+ 5 lv M latvian lv
39
+ 5 mk M macedonian-test mk
40
+ 5 ml M malayalam ml
41
+ 5 nci M nahuatl - classical test/nci
42
+ 5 nl M dutch-test nl
43
+ 5 no M norwegian no (nb 5)
44
+ 5 pap papiamento-test test/pap
45
+ 5 pl M polish pl
46
+ 5 pt M brazil pt (pt-br 5)
47
+ 5 pt-pt M portugal pt-pt
48
+ 5 ro M romanian ro
49
+ 5 ru M russian_test ru
50
+ 5 sk M slovak sk
51
+ 5 sq M albanian sq
52
+ 5 sr M serbian sr
53
+ 5 sv M swedish sv
54
+ 5 sw M swahihi-test sw
55
+ 5 ta M tamil ta
56
+ 5 tr M turkish tr
57
+ 5 vi M vietnam vi
58
+ 5 zh M Mandarin zh
59
+ 5 zh-yue M cantonese zh-yue (yue 5)(zhy 5)
60
+
data/test/test_helper.rb CHANGED
@@ -1,3 +1,4 @@
1
1
  require 'rubygems'
2
2
  require 'test/unit'
3
+ require 'mocha/setup'
3
4
  require 'espeak'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: espeak-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-01-16 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: espeak-ruby is small Ruby API for utilizing ‘espeak’ and ‘lame’ to create
15
15
  Text-To-Speech mp3 files
@@ -20,9 +20,11 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - Rakefile
22
22
  - lib/espeak/speech.rb
23
+ - lib/espeak/voice.rb
23
24
  - lib/espeak.rb
24
- - lib/hash_ext.rb
25
25
  - test/cases/speech_test.rb
26
+ - test/cases/voice_test.rb
27
+ - test/fixtures/voices.txt
26
28
  - test/test_helper.rb
27
29
  - README.md
28
30
  homepage: http://github.com/dejan/espeak-ruby
data/lib/hash_ext.rb DELETED
@@ -1,9 +0,0 @@
1
- # from ActiveSupport
2
- class Hash
3
-
4
- end
5
-
6
- def symbolize_keys!
7
- self.replace(self.symbolize_keys)
8
- end
9
- end