ruby_speech 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,2 +1,5 @@
1
+ # 0.1.1
2
+ * Bugfix: DSL now allows for nesting all allowed elements within each other
3
+
1
4
  # 0.1.0
2
- * Initial Release
5
+ * Initial Release
@@ -10,8 +10,9 @@ module RubySpeech
10
10
  end
11
11
 
12
12
  def method_missing(method_name, *args, &block)
13
- const = SSML.const_get(method_name.to_s.titleize.gsub(' ', ''))
14
- if const && self.valid_child_type?(const)
13
+ const_name = method_name.to_s.sub('ssml', '').titleize.gsub(' ', '')
14
+ const = SSML.const_get const_name
15
+ if const && self.class::VALID_CHILD_TYPES.include?(const)
15
16
  self << const.new(*args, &block)
16
17
  else
17
18
  super
@@ -45,10 +45,6 @@ module RubySpeech
45
45
  super
46
46
  end
47
47
 
48
- def valid_child_type?(type)
49
- VALID_CHILD_TYPES.include? type
50
- end
51
-
52
48
  def eql?(o)
53
49
  super o, :language, :base_uri
54
50
  end
@@ -104,19 +104,11 @@ module RubySpeech
104
104
  write_attr :name, n
105
105
  end
106
106
 
107
- def valid_child_types
108
- VALID_CHILD_TYPES
109
- end
110
-
111
107
  def <<(arg)
112
108
  raise InvalidChildError, "A Voice can only accept String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, SayAs, Sub, S, Voice as children" unless VALID_CHILD_TYPES.include? arg.class
113
109
  super
114
110
  end
115
111
 
116
- def valid_child_type?(type)
117
- VALID_CHILD_TYPES.include? type
118
- end
119
-
120
112
  def eql?(o)
121
113
  super o, :language, :gender, :age, :variant, :name
122
114
  end
@@ -1,3 +1,3 @@
1
1
  module RubySpeech
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/ruby_speech.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = RubySpeech::VERSION
8
8
  s.authors = ["Ben Langfeld"]
9
9
  s.email = ["ben@langfeld.me"]
10
- s.homepage = "https://github.com/mojolingo/ruby_speech"
10
+ s.homepage = "https://github.com/benlangfeld/ruby_speech"
11
11
  s.summary = %q{A ruby library for TTS & ASR document preparation}
12
12
  s.description = %q{Prepare SSML and GRXML documents with ease}
13
13
 
@@ -60,6 +60,74 @@ module RubySpeech
60
60
  expected_doc << speak
61
61
  doc.should == expected_doc.to_s
62
62
  end
63
+
64
+ it "should allow all permutations of possible nested SSML elements" do
65
+ doc = RubySpeech::SSML.draw do
66
+ string "Hello world."
67
+ ssml_break
68
+ emphasis do
69
+ string "HELLO?"
70
+ ssml_break
71
+ emphasis
72
+ prosody
73
+ say_as 'date'
74
+ voice
75
+ end
76
+ prosody rate: :slow do
77
+ string "H...E...L...L...O?"
78
+ ssml_break
79
+ emphasis
80
+ prosody
81
+ say_as 'date'
82
+ voice
83
+ end
84
+ say_as 'date', format: 'dmy' do
85
+ "01/02/1960"
86
+ end
87
+ voice gender: :male, name: 'fred' do
88
+ string "Hi, I'm Fred. The time is currently "
89
+ say_as 'date', format: 'dmy' do
90
+ "01/02/1960"
91
+ end
92
+ ssml_break
93
+ emphasis do
94
+ "I'm so old"
95
+ end
96
+ prosody rate: :fast do
97
+ "And yet so spritely!"
98
+ end
99
+ voice age: 12 do
100
+ "And I'm young Fred"
101
+ end
102
+ end
103
+ end
104
+ speak = SSML::Speak.new(content: "Hello world.")
105
+ speak << SSML::Break.new
106
+ emphasis = SSML::Emphasis.new(content: "HELLO?")
107
+ emphasis << SSML::Break.new
108
+ emphasis << SSML::Emphasis.new
109
+ emphasis << SSML::Prosody.new
110
+ emphasis << SSML::SayAs.new('date')
111
+ emphasis << SSML::Voice.new
112
+ speak << emphasis
113
+ prosody = SSML::Prosody.new(rate: :slow, content: "H...E...L...L...O?")
114
+ prosody << SSML::Break.new
115
+ prosody << SSML::Emphasis.new
116
+ prosody << SSML::Prosody.new
117
+ prosody << SSML::SayAs.new('date')
118
+ prosody << SSML::Voice.new
119
+ speak << prosody
120
+ speak << SSML::SayAs.new('date', format: 'dmy', content: "01/02/1960")
121
+ voice = SSML::Voice.new(gender: :male, name: 'fred', content: "Hi, I'm Fred. The time is currently ")
122
+ voice << SSML::SayAs.new('date', format: 'dmy', content: "01/02/1960")
123
+ voice << SSML::Break.new
124
+ voice << SSML::Emphasis.new(content: "I'm so old")
125
+ voice << SSML::Prosody.new(rate: :fast, content: "And yet so spritely!")
126
+ voice << SSML::Voice.new(age: 12, content: "And I'm young Fred")
127
+ speak << voice
128
+ expected_doc << speak
129
+ doc.should == expected_doc.to_s
130
+ end
63
131
  end
64
132
  end
65
133
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 1
9
+ version: 0.1.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ben Langfeld
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-07-02 00:00:00 +01:00
17
+ date: 2011-07-07 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -189,7 +189,7 @@ files:
189
189
  - spec/spec_helper.rb
190
190
  - spec/support/matchers.rb
191
191
  has_rdoc: true
192
- homepage: https://github.com/mojolingo/ruby_speech
192
+ homepage: https://github.com/benlangfeld/ruby_speech
193
193
  licenses: []
194
194
 
195
195
  post_install_message: