ruby_speech 0.1.5 → 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/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/ruby_speech/ssml/audio.rb +3 -1
- data/lib/ruby_speech/ssml/break.rb +2 -0
- data/lib/ruby_speech/ssml/element.rb +61 -1
- data/lib/ruby_speech/ssml/emphasis.rb +3 -1
- data/lib/ruby_speech/ssml/prosody.rb +4 -1
- data/lib/ruby_speech/ssml/say_as.rb +5 -3
- data/lib/ruby_speech/ssml/speak.rb +7 -4
- data/lib/ruby_speech/ssml/voice.rb +3 -1
- data/lib/ruby_speech/ssml.rb +2 -0
- data/lib/ruby_speech/version.rb +1 -1
- data/spec/ruby_speech/ssml/audio_spec.rb +15 -0
- data/spec/ruby_speech/ssml/break_spec.rb +15 -0
- data/spec/ruby_speech/ssml/emphasis_spec.rb +14 -0
- data/spec/ruby_speech/ssml/prosody_spec.rb +19 -0
- data/spec/ruby_speech/ssml/say_as_spec.rb +20 -10
- data/spec/ruby_speech/ssml/speak_spec.rb +26 -0
- data/spec/ruby_speech/ssml/voice_spec.rb +18 -0
- data/spec/ruby_speech/ssml_spec.rb +34 -12
- metadata +20 -20
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# 0.2.0
|
2
|
+
Feature: SSML elements can now be imported from a Nokogiri Node or a string
|
3
|
+
Feature: SSML elements now respond to #children with an array of SSML elements, rather than a Nokogiri NodeSet
|
4
|
+
Bugfix/Feature: Comparing SSML elements now compares children
|
5
|
+
|
1
6
|
# 0.1.5
|
2
7
|
Feature: Now added support for SSML <audio/>
|
3
8
|
|
data/README.md
CHANGED
@@ -14,7 +14,9 @@ module RubySpeech
|
|
14
14
|
#
|
15
15
|
class Audio < Element
|
16
16
|
|
17
|
-
|
17
|
+
register :audio
|
18
|
+
|
19
|
+
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text,String, Audio, Break, Emphasis, Prosody, SayAs, Voice].freeze
|
18
20
|
|
19
21
|
##
|
20
22
|
# Create a new SSML audio element
|
@@ -1,6 +1,62 @@
|
|
1
|
+
require 'active_support/core_ext/class/inheritable_attributes'
|
2
|
+
|
1
3
|
module RubySpeech
|
2
4
|
module SSML
|
3
5
|
class Element < Niceogiri::XML::Node
|
6
|
+
@@registrations = {}
|
7
|
+
|
8
|
+
class_inheritable_accessor :registered_ns, :registered_name
|
9
|
+
|
10
|
+
# Register a new stanza class to a name and/or namespace
|
11
|
+
#
|
12
|
+
# This registers a namespace that is used when looking
|
13
|
+
# up the class name of the object to instantiate when a new
|
14
|
+
# stanza is received
|
15
|
+
#
|
16
|
+
# @param [#to_s] name the name of the node
|
17
|
+
#
|
18
|
+
def self.register(name)
|
19
|
+
self.registered_name = name.to_s
|
20
|
+
self.registered_ns = SSML_NAMESPACE
|
21
|
+
@@registrations[[self.registered_name, self.registered_ns]] = self
|
22
|
+
end
|
23
|
+
|
24
|
+
# Find the class to use given the name and namespace of a stanza
|
25
|
+
#
|
26
|
+
# @param [#to_s] name the name to lookup
|
27
|
+
#
|
28
|
+
# @return [Class, nil] the class appropriate for the name
|
29
|
+
def self.class_from_registration(name)
|
30
|
+
@@registrations[[name.to_s, SSML_NAMESPACE]]
|
31
|
+
end
|
32
|
+
|
33
|
+
# Import an XML::Node to the appropriate class
|
34
|
+
#
|
35
|
+
# Looks up the class the node should be then creates it based on the
|
36
|
+
# elements of the XML::Node
|
37
|
+
# @param [XML::Node] node the node to import
|
38
|
+
# @return the appropriate object based on the node name and namespace
|
39
|
+
def self.import(node)
|
40
|
+
klass = class_from_registration(node.element_name)
|
41
|
+
event = if klass && klass != self
|
42
|
+
klass.import node
|
43
|
+
else
|
44
|
+
new.inherit node
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# Inherit the attributes and children of an XML::Node
|
49
|
+
#
|
50
|
+
# @param [XML::Node] node the node to inherit
|
51
|
+
# @return [self]
|
52
|
+
def inherit(node)
|
53
|
+
inherit_attrs node.attributes
|
54
|
+
node.children.each do |c|
|
55
|
+
self << c.dup
|
56
|
+
end
|
57
|
+
self
|
58
|
+
end
|
59
|
+
|
4
60
|
def self.new(element_name, atts = {}, &block)
|
5
61
|
super(element_name) do |new_node|
|
6
62
|
atts.each_pair { |k, v| new_node.send :"#{k}=", v }
|
@@ -9,6 +65,10 @@ module RubySpeech
|
|
9
65
|
end
|
10
66
|
end
|
11
67
|
|
68
|
+
def children
|
69
|
+
super.reject { |c| c.is_a?(Nokogiri::XML::Text) }.map { |c| Element.import c }
|
70
|
+
end
|
71
|
+
|
12
72
|
def method_missing(method_name, *args, &block)
|
13
73
|
const_name = method_name.to_s.sub('ssml', '').titleize.gsub(' ', '')
|
14
74
|
const = SSML.const_get const_name
|
@@ -24,7 +84,7 @@ module RubySpeech
|
|
24
84
|
end
|
25
85
|
|
26
86
|
def eql?(o, *args)
|
27
|
-
super o, :content, *args
|
87
|
+
super o, :content, :children, *args
|
28
88
|
end
|
29
89
|
end # Element
|
30
90
|
end # SSML
|
@@ -7,8 +7,10 @@ module RubySpeech
|
|
7
7
|
#
|
8
8
|
class Emphasis < Element
|
9
9
|
|
10
|
+
register :emphasis
|
11
|
+
|
10
12
|
VALID_LEVELS = [:strong, :moderate, :none, :reduced].freeze
|
11
|
-
VALID_CHILD_TYPES = [String, Audio, Break, Emphasis, Prosody, SayAs, Voice].freeze
|
13
|
+
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Prosody, SayAs, Voice].freeze
|
12
14
|
|
13
15
|
##
|
14
16
|
# Create a new SSML emphasis element
|
@@ -13,10 +13,12 @@ module RubySpeech
|
|
13
13
|
#
|
14
14
|
class Prosody < Element
|
15
15
|
|
16
|
+
register :prosody
|
17
|
+
|
16
18
|
VALID_PITCHES = [:'x-low', :low, :medium, :high, :'x-high', :default].freeze
|
17
19
|
VALID_VOLUMES = [:silent, :'x-soft', :soft, :medium, :loud, :'x-loud', :default].freeze
|
18
20
|
VALID_RATES = [:'x-slow', :slow, :medium, :fast, :'x-fast', :default].freeze
|
19
|
-
VALID_CHILD_TYPES = [String, Audio, Break, Emphasis, Prosody, SayAs, Voice].freeze
|
21
|
+
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Prosody, SayAs, Voice].freeze
|
20
22
|
|
21
23
|
##
|
22
24
|
# Create a new SSML prosody element
|
@@ -150,6 +152,7 @@ module RubySpeech
|
|
150
152
|
#
|
151
153
|
def volume
|
152
154
|
value = read_attr :volume
|
155
|
+
return unless value
|
153
156
|
if VALID_VOLUMES.include?(value.to_sym)
|
154
157
|
value.to_sym
|
155
158
|
else
|
@@ -22,7 +22,9 @@ module RubySpeech
|
|
22
22
|
#
|
23
23
|
class SayAs < Element
|
24
24
|
|
25
|
-
|
25
|
+
register :'say-as'
|
26
|
+
|
27
|
+
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String].freeze
|
26
28
|
|
27
29
|
##
|
28
30
|
# Create a new SSML say-as element
|
@@ -31,8 +33,8 @@ module RubySpeech
|
|
31
33
|
#
|
32
34
|
# @return [Prosody] an element for use in an SSML document
|
33
35
|
#
|
34
|
-
def self.new(
|
35
|
-
super 'say-as', atts
|
36
|
+
def self.new(atts = {}, &block)
|
37
|
+
super 'say-as', atts, &block
|
36
38
|
end
|
37
39
|
|
38
40
|
##
|
@@ -8,7 +8,9 @@ module RubySpeech
|
|
8
8
|
class Speak < Element
|
9
9
|
include XML::Language
|
10
10
|
|
11
|
-
|
11
|
+
register :speak
|
12
|
+
|
13
|
+
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio, Break, Emphasis, Prosody, SayAs, Voice].freeze
|
12
14
|
|
13
15
|
##
|
14
16
|
# Create a new SSML speak root element
|
@@ -20,7 +22,7 @@ module RubySpeech
|
|
20
22
|
def self.new(atts = {}, &block)
|
21
23
|
new_node = super('speak', atts)
|
22
24
|
new_node[:version] = '1.0'
|
23
|
-
new_node.namespace =
|
25
|
+
new_node.namespace = SSML_NAMESPACE
|
24
26
|
new_node.language ||= "en-US"
|
25
27
|
new_node.instance_eval &block if block_given?
|
26
28
|
new_node
|
@@ -53,8 +55,9 @@ module RubySpeech
|
|
53
55
|
|
54
56
|
def +(other)
|
55
57
|
self.class.new(:base_uri => base_uri).tap do |new_speak|
|
56
|
-
|
57
|
-
|
58
|
+
(self.children + other.children).each do |child|
|
59
|
+
new_speak << child
|
60
|
+
end
|
58
61
|
end
|
59
62
|
end
|
60
63
|
|
@@ -8,8 +8,10 @@ module RubySpeech
|
|
8
8
|
class Voice < Element
|
9
9
|
include XML::Language
|
10
10
|
|
11
|
+
register :voice
|
12
|
+
|
11
13
|
VALID_GENDERS = [:male, :female, :neutral].freeze
|
12
|
-
VALID_CHILD_TYPES = [String, Audio,Break, Emphasis, Prosody, SayAs, Voice].freeze
|
14
|
+
VALID_CHILD_TYPES = [Nokogiri::XML::Element, Nokogiri::XML::Text, String, Audio,Break, Emphasis, Prosody, SayAs, Voice].freeze
|
13
15
|
|
14
16
|
##
|
15
17
|
# Create a new SSML voice element
|
data/lib/ruby_speech/ssml.rb
CHANGED
data/lib/ruby_speech/version.rb
CHANGED
@@ -12,6 +12,21 @@ module RubySpeech
|
|
12
12
|
its(:content) { should == 'Hello' }
|
13
13
|
end
|
14
14
|
|
15
|
+
it 'registers itself' do
|
16
|
+
Element.class_from_registration(:audio).should == Audio
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "from a document" do
|
20
|
+
let(:document) { '<audio src="http://whatever.you-say-boss.com">Hello</audio>' }
|
21
|
+
|
22
|
+
subject { Element.import parse_xml(document).root }
|
23
|
+
|
24
|
+
it { should be_instance_of Audio }
|
25
|
+
|
26
|
+
its(:src) { should == 'http://whatever.you-say-boss.com' }
|
27
|
+
its(:content) { should == 'Hello' }
|
28
|
+
end
|
29
|
+
|
15
30
|
describe "#src" do
|
16
31
|
before { subject.src = 'http://whatever.you-say-boss.com' }
|
17
32
|
|
@@ -12,6 +12,21 @@ module RubySpeech
|
|
12
12
|
its(:time) { should == 3.seconds }
|
13
13
|
end
|
14
14
|
|
15
|
+
it 'registers itself' do
|
16
|
+
Element.class_from_registration(:break).should == Break
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "from a document" do
|
20
|
+
let(:document) { '<break strength="strong" time="3"/>' }
|
21
|
+
|
22
|
+
subject { Element.import parse_xml(document).root }
|
23
|
+
|
24
|
+
it { should be_instance_of Break }
|
25
|
+
|
26
|
+
its(:strength) { should == :strong }
|
27
|
+
its(:time) { should == 3.seconds }
|
28
|
+
end
|
29
|
+
|
15
30
|
describe "#strength" do
|
16
31
|
before { subject.strength = :strong }
|
17
32
|
|
@@ -11,6 +11,20 @@ module RubySpeech
|
|
11
11
|
its(:level) { should == :strong }
|
12
12
|
end
|
13
13
|
|
14
|
+
it 'registers itself' do
|
15
|
+
Element.class_from_registration(:emphasis).should == Emphasis
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "from a document" do
|
19
|
+
let(:document) { '<emphasis level="strong"/>' }
|
20
|
+
|
21
|
+
subject { Element.import parse_xml(document).root }
|
22
|
+
|
23
|
+
it { should be_instance_of Emphasis }
|
24
|
+
|
25
|
+
its(:level) { should == :strong }
|
26
|
+
end
|
27
|
+
|
14
28
|
describe "#level" do
|
15
29
|
before { subject.level = :strong }
|
16
30
|
|
@@ -16,6 +16,25 @@ module RubySpeech
|
|
16
16
|
its(:volume) { should == :loud }
|
17
17
|
end
|
18
18
|
|
19
|
+
it 'registers itself' do
|
20
|
+
Element.class_from_registration(:prosody).should == Prosody
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "from a document" do
|
24
|
+
let(:document) { '<prosody pitch="medium" contour="something" range="20Hz" rate="2" duration="10" volume="loud"/>' }
|
25
|
+
|
26
|
+
subject { Element.import parse_xml(document).root }
|
27
|
+
|
28
|
+
it { should be_instance_of Prosody }
|
29
|
+
|
30
|
+
its(:pitch) { should == :medium }
|
31
|
+
its(:contour) { should == 'something' }
|
32
|
+
its(:range) { should == '20Hz' }
|
33
|
+
its(:rate) { should == 2 }
|
34
|
+
its(:duration) { should == 10.seconds }
|
35
|
+
its(:volume) { should == :loud }
|
36
|
+
end
|
37
|
+
|
19
38
|
describe "#pitch" do
|
20
39
|
context "with a pre-defined value" do
|
21
40
|
before { subject.pitch = :medium }
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
module RubySpeech
|
4
4
|
module SSML
|
5
5
|
describe SayAs do
|
6
|
-
subject { SayAs.new 'one', :format => 'two', :detail => 'three' }
|
6
|
+
subject { SayAs.new :interpret_as => 'one', :format => 'two', :detail => 'three' }
|
7
7
|
|
8
8
|
its(:name) { should == 'say-as' }
|
9
9
|
|
@@ -11,38 +11,48 @@ module RubySpeech
|
|
11
11
|
its(:format) { should == 'two' }
|
12
12
|
its(:detail) { should == 'three' }
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
it 'registers itself' do
|
15
|
+
Element.class_from_registration(:'say-as').should == SayAs
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "from a document" do
|
19
|
+
let(:document) { '<say-as interpret-as="one" format="two" detail="three"/>' }
|
20
|
+
|
21
|
+
subject { Element.import parse_xml(document).root }
|
22
|
+
|
23
|
+
it { should be_instance_of SayAs }
|
24
|
+
|
25
|
+
its(:interpret_as) { should == 'one' }
|
26
|
+
its(:format) { should == 'two' }
|
27
|
+
its(:detail) { should == 'three' }
|
18
28
|
end
|
19
29
|
|
20
30
|
describe "comparing objects" do
|
21
31
|
it "should be equal if the content, interpret_as, format, age, variant, name are the same" do
|
22
|
-
SayAs.new('jp', :format => 'foo', :detail => 'bar', :content => "hello").should == SayAs.new('jp', :format => 'foo', :detail => 'bar', :content => "hello")
|
32
|
+
SayAs.new(:interpret_as => 'jp', :format => 'foo', :detail => 'bar', :content => "hello").should == SayAs.new(:interpret_as => 'jp', :format => 'foo', :detail => 'bar', :content => "hello")
|
23
33
|
end
|
24
34
|
|
25
35
|
describe "when the content is different" do
|
26
36
|
it "should not be equal" do
|
27
|
-
SayAs.new('jp', :content => "Hello").should_not == SayAs.new('jp', :content => "Hello there")
|
37
|
+
SayAs.new(:interpret_as => 'jp', :content => "Hello").should_not == SayAs.new(:interpret_as => 'jp', :content => "Hello there")
|
28
38
|
end
|
29
39
|
end
|
30
40
|
|
31
41
|
describe "when the interpret_as is different" do
|
32
42
|
it "should not be equal" do
|
33
|
-
SayAs.new("Hello").should_not == SayAs.new("Hello there")
|
43
|
+
SayAs.new(:interpret_as => "Hello").should_not == SayAs.new(:interpret_as => "Hello there")
|
34
44
|
end
|
35
45
|
end
|
36
46
|
|
37
47
|
describe "when the format is different" do
|
38
48
|
it "should not be equal" do
|
39
|
-
SayAs.new('jp', :format => 'foo').should_not == SayAs.new('jp', :format => 'bar')
|
49
|
+
SayAs.new(:interpret_as => 'jp', :format => 'foo').should_not == SayAs.new(:interpret_as => 'jp', :format => 'bar')
|
40
50
|
end
|
41
51
|
end
|
42
52
|
|
43
53
|
describe "when the detail is different" do
|
44
54
|
it "should not be equal" do
|
45
|
-
SayAs.new('jp', :detail => 'foo').should_not == SayAs.new('jp', :detail => 'bar')
|
55
|
+
SayAs.new(:interpret_as => 'jp', :detail => 'foo').should_not == SayAs.new(:interpret_as => 'jp', :detail => 'bar')
|
46
56
|
end
|
47
57
|
end
|
48
58
|
end
|
@@ -15,6 +15,21 @@ module RubySpeech
|
|
15
15
|
its(:base_uri) { should == 'blah' }
|
16
16
|
end
|
17
17
|
|
18
|
+
it 'registers itself' do
|
19
|
+
Element.class_from_registration(:speak).should == Speak
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "from a document" do
|
23
|
+
let(:document) { '<speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="jp" xml:base="blah"/>' }
|
24
|
+
|
25
|
+
subject { Element.import parse_xml(document).root }
|
26
|
+
|
27
|
+
it { should be_instance_of Speak }
|
28
|
+
|
29
|
+
its(:language) { pending; should == 'jp' }
|
30
|
+
its(:base_uri) { should == 'blah' }
|
31
|
+
end
|
32
|
+
|
18
33
|
describe "#language" do
|
19
34
|
before { subject.language = 'jp' }
|
20
35
|
|
@@ -49,6 +64,17 @@ module RubySpeech
|
|
49
64
|
Speak.new(:base_uri => 'foo').should_not == Speak.new(:base_uri => 'bar')
|
50
65
|
end
|
51
66
|
end
|
67
|
+
|
68
|
+
describe "when the children are different" do
|
69
|
+
it "should not be equal" do
|
70
|
+
s1 = Speak.new
|
71
|
+
s1 << SayAs.new(:interpret_as => 'date')
|
72
|
+
s2 = Speak.new
|
73
|
+
s2 << SayAs.new(:interpret_as => 'time')
|
74
|
+
|
75
|
+
s1.should_not == s2
|
76
|
+
end
|
77
|
+
end
|
52
78
|
end
|
53
79
|
|
54
80
|
it "should allow creating child SSML elements" do
|
@@ -16,6 +16,24 @@ module RubySpeech
|
|
16
16
|
its(:name) { should == 'paul' }
|
17
17
|
end
|
18
18
|
|
19
|
+
it 'registers itself' do
|
20
|
+
Element.class_from_registration(:voice).should == Voice
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "from a document" do
|
24
|
+
let(:document) { '<voice xml:lang="jp" gender="male" age="25" variant="2" name="paul"/>' }
|
25
|
+
|
26
|
+
subject { Element.import parse_xml(document).root }
|
27
|
+
|
28
|
+
it { should be_instance_of Voice }
|
29
|
+
|
30
|
+
its(:language) { should == 'jp' }
|
31
|
+
its(:gender) { should == :male }
|
32
|
+
its(:age) { should == 25 }
|
33
|
+
its(:variant) { should == 2 }
|
34
|
+
its(:name) { should == 'paul' }
|
35
|
+
end
|
36
|
+
|
19
37
|
describe "#language" do
|
20
38
|
before { subject.language = 'jp' }
|
21
39
|
|
@@ -44,13 +44,13 @@ module RubySpeech
|
|
44
44
|
doc = RubySpeech::SSML.draw do
|
45
45
|
voice :gender => :male, :name => 'fred' do
|
46
46
|
string "Hi, I'm Fred. The time is currently "
|
47
|
-
say_as 'date', :format => 'dmy' do
|
47
|
+
say_as :interpret_as => 'date', :format => 'dmy' do
|
48
48
|
"01/02/1960"
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
52
52
|
voice = SSML::Voice.new(:gender => :male, :name => 'fred', :content => "Hi, I'm Fred. The time is currently ")
|
53
|
-
voice << SSML::SayAs.new('date', :format => 'dmy', :content => "01/02/1960")
|
53
|
+
voice << SSML::SayAs.new(:interpret_as => 'date', :format => 'dmy', :content => "01/02/1960")
|
54
54
|
expected_doc = SSML::Speak.new
|
55
55
|
expected_doc << voice
|
56
56
|
doc.should == expected_doc
|
@@ -78,7 +78,7 @@ module RubySpeech
|
|
78
78
|
audio :src => "hello"
|
79
79
|
emphasis
|
80
80
|
prosody
|
81
|
-
say_as 'date'
|
81
|
+
say_as :interpret_as => 'date'
|
82
82
|
voice
|
83
83
|
end
|
84
84
|
emphasis do
|
@@ -87,7 +87,7 @@ module RubySpeech
|
|
87
87
|
audio :src => "hello"
|
88
88
|
emphasis
|
89
89
|
prosody
|
90
|
-
say_as 'date'
|
90
|
+
say_as :interpret_as => 'date'
|
91
91
|
voice
|
92
92
|
end
|
93
93
|
prosody :rate => :slow do
|
@@ -96,15 +96,15 @@ module RubySpeech
|
|
96
96
|
audio :src => "hello"
|
97
97
|
emphasis
|
98
98
|
prosody
|
99
|
-
say_as 'date'
|
99
|
+
say_as :interpret_as => 'date'
|
100
100
|
voice
|
101
101
|
end
|
102
|
-
say_as 'date', :format => 'dmy' do
|
102
|
+
say_as :interpret_as => 'date', :format => 'dmy' do
|
103
103
|
"01/02/1960"
|
104
104
|
end
|
105
105
|
voice :gender => :male, :name => 'fred' do
|
106
106
|
string "Hi, I'm Fred. The time is currently "
|
107
|
-
say_as 'date', :format => 'dmy' do
|
107
|
+
say_as :interpret_as => 'date', :format => 'dmy' do
|
108
108
|
"01/02/1960"
|
109
109
|
end
|
110
110
|
ssml_break
|
@@ -127,7 +127,7 @@ module RubySpeech
|
|
127
127
|
audio << SSML::Audio.new(:src => "hello")
|
128
128
|
audio << SSML::Emphasis.new
|
129
129
|
audio << SSML::Prosody.new
|
130
|
-
audio << SSML::SayAs.new('date')
|
130
|
+
audio << SSML::SayAs.new(:interpret_as => 'date')
|
131
131
|
audio << SSML::Voice.new
|
132
132
|
expected_doc << audio
|
133
133
|
emphasis = SSML::Emphasis.new(:content => "HELLO?")
|
@@ -135,7 +135,7 @@ module RubySpeech
|
|
135
135
|
emphasis << SSML::Audio.new(:src => "hello")
|
136
136
|
emphasis << SSML::Emphasis.new
|
137
137
|
emphasis << SSML::Prosody.new
|
138
|
-
emphasis << SSML::SayAs.new('date')
|
138
|
+
emphasis << SSML::SayAs.new(:interpret_as => 'date')
|
139
139
|
emphasis << SSML::Voice.new
|
140
140
|
expected_doc << emphasis
|
141
141
|
prosody = SSML::Prosody.new(:rate => :slow, :content => "H...E...L...L...O?")
|
@@ -143,12 +143,12 @@ module RubySpeech
|
|
143
143
|
prosody << SSML::Audio.new(:src => "hello")
|
144
144
|
prosody << SSML::Emphasis.new
|
145
145
|
prosody << SSML::Prosody.new
|
146
|
-
prosody << SSML::SayAs.new('date')
|
146
|
+
prosody << SSML::SayAs.new(:interpret_as => 'date')
|
147
147
|
prosody << SSML::Voice.new
|
148
148
|
expected_doc << prosody
|
149
|
-
expected_doc << SSML::SayAs.new('date', :format => 'dmy', :content => "01/02/1960")
|
149
|
+
expected_doc << SSML::SayAs.new(:interpret_as => 'date', :format => 'dmy', :content => "01/02/1960")
|
150
150
|
voice = SSML::Voice.new(:gender => :male, :name => 'fred', :content => "Hi, I'm Fred. The time is currently ")
|
151
|
-
voice << SSML::SayAs.new('date', :format => 'dmy', :content => "01/02/1960")
|
151
|
+
voice << SSML::SayAs.new(:interpret_as => 'date', :format => 'dmy', :content => "01/02/1960")
|
152
152
|
voice << SSML::Break.new
|
153
153
|
voice << SSML::Audio.new(:src => "hello")
|
154
154
|
voice << SSML::Emphasis.new(:content => "I'm so old")
|
@@ -158,5 +158,27 @@ module RubySpeech
|
|
158
158
|
doc.should == expected_doc
|
159
159
|
end
|
160
160
|
end
|
161
|
+
|
162
|
+
describe "importing nested tags" do
|
163
|
+
let :voice do
|
164
|
+
SSML::Voice.new(:gender => :male, :name => 'fred', :content => "Hi, I'm Fred. The time is currently ").tap do |voice|
|
165
|
+
voice << SSML::SayAs.new(:interpret_as => 'date', :format => 'dmy', :content => "01/02/1960")
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
let :document do
|
170
|
+
SSML::Speak.new.tap { |doc| doc << voice }.to_s
|
171
|
+
end
|
172
|
+
|
173
|
+
subject { SSML::Element.import parse_xml(document).root }
|
174
|
+
|
175
|
+
it "should work" do
|
176
|
+
lambda { subject }.should_not raise_error
|
177
|
+
end
|
178
|
+
|
179
|
+
it { should be_a SSML::Speak }
|
180
|
+
|
181
|
+
its(:children) { should == [voice] }
|
182
|
+
end
|
161
183
|
end
|
162
184
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_speech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-26 00:00:00.000000000 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: niceogiri
|
17
|
-
requirement: &
|
17
|
+
requirement: &2152713180 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.0.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2152713180
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &2152712660 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 3.0.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2152712660
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &2152712180 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2152712180
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &2152711700 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 2.3.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2152711700
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: ci_reporter
|
61
|
-
requirement: &
|
61
|
+
requirement: &2152711220 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 1.6.3
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2152711220
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: yard
|
72
|
-
requirement: &
|
72
|
+
requirement: &2152710740 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.7.0
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2152710740
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rake
|
83
|
-
requirement: &
|
83
|
+
requirement: &2152710260 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2152710260
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: mocha
|
94
|
-
requirement: &
|
94
|
+
requirement: &2152709780 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2152709780
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: i18n
|
105
|
-
requirement: &
|
105
|
+
requirement: &2152709300 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *2152709300
|
114
114
|
description: Prepare SSML and GRXML documents with ease
|
115
115
|
email:
|
116
116
|
- ben@langfeld.me
|