Permalink
Browse files

Merge branch 'release/0.1.1'

  • Loading branch information...
2 parents 69ae194 + b608ac5 commit b0221aa88eadcc238c97a6d9ef65a29dde758e72 @benlangfeld benlangfeld committed Jul 7, 2011
View
@@ -1,2 +1,5 @@
+# 0.1.1
+ * Bugfix: DSL now allows for nesting all allowed elements within each other
+
# 0.1.0
- * Initial Release
+ * Initial Release
@@ -10,8 +10,9 @@ def self.new(element_name, atts = {}, &block)
end
def method_missing(method_name, *args, &block)
- const = SSML.const_get(method_name.to_s.titleize.gsub(' ', ''))
- if const && self.valid_child_type?(const)
+ const_name = method_name.to_s.sub('ssml', '').titleize.gsub(' ', '')
+ const = SSML.const_get const_name
+ if const && self.class::VALID_CHILD_TYPES.include?(const)
self << const.new(*args, &block)
else
super
@@ -45,10 +45,6 @@ def <<(arg)
super
end
- def valid_child_type?(type)
- VALID_CHILD_TYPES.include? type
- end
-
def eql?(o)
super o, :language, :base_uri
end
@@ -104,19 +104,11 @@ def name=(n)
write_attr :name, n
end
- def valid_child_types
- VALID_CHILD_TYPES
- end
-
def <<(arg)
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
super
end
- def valid_child_type?(type)
- VALID_CHILD_TYPES.include? type
- end
-
def eql?(o)
super o, :language, :gender, :age, :variant, :name
end
@@ -1,3 +1,3 @@
module RubySpeech
- VERSION = "0.1.0"
+ VERSION = "0.1.1"
end
View
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
s.version = RubySpeech::VERSION
s.authors = ["Ben Langfeld"]
s.email = ["ben@langfeld.me"]
- s.homepage = "https://github.com/mojolingo/ruby_speech"
+ s.homepage = "https://github.com/benlangfeld/ruby_speech"
s.summary = %q{A ruby library for TTS & ASR document preparation}
s.description = %q{Prepare SSML and GRXML documents with ease}
@@ -60,6 +60,74 @@ module RubySpeech
expected_doc << speak
doc.should == expected_doc.to_s
end
+
+ it "should allow all permutations of possible nested SSML elements" do
+ doc = RubySpeech::SSML.draw do
+ string "Hello world."
+ ssml_break
+ emphasis do
+ string "HELLO?"
+ ssml_break
+ emphasis
+ prosody
+ say_as 'date'
+ voice
+ end
+ prosody rate: :slow do
+ string "H...E...L...L...O?"
+ ssml_break
+ emphasis
+ prosody
+ say_as 'date'
+ voice
+ end
+ say_as 'date', format: 'dmy' do
+ "01/02/1960"
+ end
+ voice gender: :male, name: 'fred' do
+ string "Hi, I'm Fred. The time is currently "
+ say_as 'date', format: 'dmy' do
+ "01/02/1960"
+ end
+ ssml_break
+ emphasis do
+ "I'm so old"
+ end
+ prosody rate: :fast do
+ "And yet so spritely!"
+ end
+ voice age: 12 do
+ "And I'm young Fred"
+ end
+ end
+ end
+ speak = SSML::Speak.new(content: "Hello world.")
+ speak << SSML::Break.new
+ emphasis = SSML::Emphasis.new(content: "HELLO?")
+ emphasis << SSML::Break.new
+ emphasis << SSML::Emphasis.new
+ emphasis << SSML::Prosody.new
+ emphasis << SSML::SayAs.new('date')
+ emphasis << SSML::Voice.new
+ speak << emphasis
+ prosody = SSML::Prosody.new(rate: :slow, content: "H...E...L...L...O?")
+ prosody << SSML::Break.new
+ prosody << SSML::Emphasis.new
+ prosody << SSML::Prosody.new
+ prosody << SSML::SayAs.new('date')
+ prosody << SSML::Voice.new
+ speak << prosody
+ speak << SSML::SayAs.new('date', format: 'dmy', content: "01/02/1960")
+ voice = SSML::Voice.new(gender: :male, name: 'fred', content: "Hi, I'm Fred. The time is currently ")
+ voice << SSML::SayAs.new('date', format: 'dmy', content: "01/02/1960")
+ voice << SSML::Break.new
+ voice << SSML::Emphasis.new(content: "I'm so old")
+ voice << SSML::Prosody.new(rate: :fast, content: "And yet so spritely!")
+ voice << SSML::Voice.new(age: 12, content: "And I'm young Fred")
+ speak << voice
+ expected_doc << speak
+ doc.should == expected_doc.to_s
+ end
end
end
end

0 comments on commit b0221aa

Please sign in to comment.