ruby_speech 2.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +17 -0
- data/CHANGELOG.md +144 -0
- data/Gemfile +3 -0
- data/Guardfile +9 -0
- data/LICENSE.md +20 -0
- data/README.md +314 -0
- data/Rakefile +34 -0
- data/assets/grammar-core.xsd +317 -0
- data/assets/grammar.xsd +37 -0
- data/assets/synthesis-core.xsd +445 -0
- data/assets/synthesis.xsd +63 -0
- data/assets/xml.xsd +287 -0
- data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +64 -0
- data/ext/ruby_speech/RubySpeechService.java +23 -0
- data/ext/ruby_speech/extconf.rb +7 -0
- data/ext/ruby_speech/ruby_speech.c +97 -0
- data/lib/ruby_speech/generic_element.rb +169 -0
- data/lib/ruby_speech/grxml/element.rb +29 -0
- data/lib/ruby_speech/grxml/grammar.rb +189 -0
- data/lib/ruby_speech/grxml/item.rb +144 -0
- data/lib/ruby_speech/grxml/match.rb +16 -0
- data/lib/ruby_speech/grxml/matcher.rb +126 -0
- data/lib/ruby_speech/grxml/max_match.rb +6 -0
- data/lib/ruby_speech/grxml/no_match.rb +10 -0
- data/lib/ruby_speech/grxml/one_of.rb +31 -0
- data/lib/ruby_speech/grxml/potential_match.rb +10 -0
- data/lib/ruby_speech/grxml/rule.rb +73 -0
- data/lib/ruby_speech/grxml/ruleref.rb +69 -0
- data/lib/ruby_speech/grxml/tag.rb +29 -0
- data/lib/ruby_speech/grxml/token.rb +31 -0
- data/lib/ruby_speech/grxml.rb +39 -0
- data/lib/ruby_speech/nlsml/builder.rb +34 -0
- data/lib/ruby_speech/nlsml/document.rb +120 -0
- data/lib/ruby_speech/nlsml.rb +18 -0
- data/lib/ruby_speech/ruby_speech.jar +0 -0
- data/lib/ruby_speech/ssml/audio.rb +47 -0
- data/lib/ruby_speech/ssml/break.rb +62 -0
- data/lib/ruby_speech/ssml/desc.rb +24 -0
- data/lib/ruby_speech/ssml/element.rb +23 -0
- data/lib/ruby_speech/ssml/emphasis.rb +44 -0
- data/lib/ruby_speech/ssml/mark.rb +43 -0
- data/lib/ruby_speech/ssml/p.rb +25 -0
- data/lib/ruby_speech/ssml/phoneme.rb +72 -0
- data/lib/ruby_speech/ssml/prosody.rb +172 -0
- data/lib/ruby_speech/ssml/s.rb +25 -0
- data/lib/ruby_speech/ssml/say_as.rb +100 -0
- data/lib/ruby_speech/ssml/speak.rb +27 -0
- data/lib/ruby_speech/ssml/sub.rb +42 -0
- data/lib/ruby_speech/ssml/voice.rb +108 -0
- data/lib/ruby_speech/ssml.rb +39 -0
- data/lib/ruby_speech/version.rb +3 -0
- data/lib/ruby_speech/xml/language.rb +13 -0
- data/lib/ruby_speech/xml.rb +11 -0
- data/lib/ruby_speech.rb +36 -0
- data/ruby_speech.gemspec +42 -0
- data/spec/ruby_speech/grxml/grammar_spec.rb +341 -0
- data/spec/ruby_speech/grxml/item_spec.rb +192 -0
- data/spec/ruby_speech/grxml/match_spec.rb +15 -0
- data/spec/ruby_speech/grxml/matcher_spec.rb +688 -0
- data/spec/ruby_speech/grxml/max_match_spec.rb +17 -0
- data/spec/ruby_speech/grxml/no_match_spec.rb +17 -0
- data/spec/ruby_speech/grxml/one_of_spec.rb +49 -0
- data/spec/ruby_speech/grxml/potential_match_spec.rb +17 -0
- data/spec/ruby_speech/grxml/rule_spec.rb +125 -0
- data/spec/ruby_speech/grxml/ruleref_spec.rb +55 -0
- data/spec/ruby_speech/grxml/tag_spec.rb +41 -0
- data/spec/ruby_speech/grxml/token_spec.rb +62 -0
- data/spec/ruby_speech/grxml_spec.rb +339 -0
- data/spec/ruby_speech/nlsml_spec.rb +353 -0
- data/spec/ruby_speech/ssml/audio_spec.rb +121 -0
- data/spec/ruby_speech/ssml/break_spec.rb +100 -0
- data/spec/ruby_speech/ssml/desc_spec.rb +57 -0
- data/spec/ruby_speech/ssml/emphasis_spec.rb +110 -0
- data/spec/ruby_speech/ssml/mark_spec.rb +53 -0
- data/spec/ruby_speech/ssml/p_spec.rb +96 -0
- data/spec/ruby_speech/ssml/phoneme_spec.rb +65 -0
- data/spec/ruby_speech/ssml/prosody_spec.rb +309 -0
- data/spec/ruby_speech/ssml/s_spec.rb +92 -0
- data/spec/ruby_speech/ssml/say_as_spec.rb +71 -0
- data/spec/ruby_speech/ssml/speak_spec.rb +166 -0
- data/spec/ruby_speech/ssml/sub_spec.rb +57 -0
- data/spec/ruby_speech/ssml/voice_spec.rb +200 -0
- data/spec/ruby_speech/ssml_spec.rb +285 -0
- data/spec/ruby_speech_spec.rb +124 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/match_examples.rb +43 -0
- data/spec/support/matchers.rb +46 -0
- metadata +405 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe Audio do
|
6
|
+
its(:name) { should == 'audio' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { Audio.new :src => 'http://whatever.you-say-boss.com', :content => 'Hello' }
|
10
|
+
|
11
|
+
its(:src) { should == 'http://whatever.you-say-boss.com' }
|
12
|
+
its(:content) { should == 'Hello' }
|
13
|
+
end
|
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 document }
|
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
|
+
|
30
|
+
describe "#src" do
|
31
|
+
before { subject.src = 'http://whatever.you-say-boss.com' }
|
32
|
+
|
33
|
+
its(:src) { should == 'http://whatever.you-say-boss.com' }
|
34
|
+
end
|
35
|
+
|
36
|
+
describe "#content" do
|
37
|
+
context "with a valid value" do
|
38
|
+
before { subject.content = "Hello" }
|
39
|
+
|
40
|
+
its(:content) { should == "Hello" }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe "<<" do
|
45
|
+
it "should accept String" do
|
46
|
+
lambda { subject << 'anything' }.should_not raise_error
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should accept Audio" do
|
50
|
+
lambda { subject << Audio.new }.should_not raise_error
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should accept Break" do
|
54
|
+
lambda { subject << Break.new }.should_not raise_error
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should accept Desc" do
|
58
|
+
lambda { subject << Desc.new }.should_not raise_error
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should accept Emphasis" do
|
62
|
+
lambda { subject << Emphasis.new }.should_not raise_error
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should accept Mark" do
|
66
|
+
lambda { subject << Mark.new }.should_not raise_error
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should accept P" do
|
70
|
+
lambda { subject << P.new }.should_not raise_error
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should accept Phoneme" do
|
74
|
+
lambda { subject << Phoneme.new }.should_not raise_error
|
75
|
+
end
|
76
|
+
|
77
|
+
it "should accept Prosody" do
|
78
|
+
lambda { subject << Prosody.new }.should_not raise_error
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should accept SayAs" do
|
82
|
+
lambda { subject << SayAs.new(:interpret_as => :foo) }.should_not raise_error
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should accept Sub" do
|
86
|
+
lambda { subject << Sub.new }.should_not raise_error
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should accept S" do
|
90
|
+
lambda { subject << S.new }.should_not raise_error
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should accept Voice" do
|
94
|
+
lambda { subject << Voice.new }.should_not raise_error
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should raise InvalidChildError with non-acceptable objects" do
|
98
|
+
lambda { subject << 1 }.should raise_error(InvalidChildError, "An Audio can only accept String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, SayAs, Sub, S, Voice as children")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe "comparing objects" do
|
103
|
+
it "should be equal if the content, and src are the same" do
|
104
|
+
Audio.new(:src => "one", :content => "Hello there").should == Audio.new(:src => "one", :content => "Hello there")
|
105
|
+
end
|
106
|
+
|
107
|
+
describe "when the content is different" do
|
108
|
+
it "should not be equal" do
|
109
|
+
Audio.new(:content => "Hello").should_not == Audio.new(:content => "Hello there")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe "when the src is different" do
|
114
|
+
it "should not be equal" do
|
115
|
+
Audio.new(:src => 'one').should_not == Audio.new(:src => 'two')
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end # Break
|
120
|
+
end # SSML
|
121
|
+
end # RubySpeech
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe Break do
|
6
|
+
its(:name) { should == 'break' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { Break.new :strength => :strong, :time => 3.seconds }
|
10
|
+
|
11
|
+
its(:strength) { should == :strong }
|
12
|
+
its(:time) { should == 3.seconds }
|
13
|
+
end
|
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 document }
|
23
|
+
|
24
|
+
it { should be_instance_of Break }
|
25
|
+
|
26
|
+
its(:strength) { should == :strong }
|
27
|
+
its(:time) { should == 3.seconds }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#strength" do
|
31
|
+
before { subject.strength = :strong }
|
32
|
+
|
33
|
+
its(:strength) { should == :strong }
|
34
|
+
|
35
|
+
it "with a valid level" do
|
36
|
+
lambda { subject.strength = :none }.should_not raise_error
|
37
|
+
lambda { subject.strength = :'x-weak' }.should_not raise_error
|
38
|
+
lambda { subject.strength = :weak }.should_not raise_error
|
39
|
+
lambda { subject.strength = :medium }.should_not raise_error
|
40
|
+
lambda { subject.strength = :strong }.should_not raise_error
|
41
|
+
lambda { subject.strength = :'x-strong' }.should_not raise_error
|
42
|
+
end
|
43
|
+
|
44
|
+
it "with an invalid strength" do
|
45
|
+
lambda { subject.strength = :something }.should raise_error(ArgumentError, "You must specify a valid strength (:none, :\"x-weak\", :weak, :medium, :strong, :\"x-strong\")")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "#time" do
|
50
|
+
context "with a valid value" do
|
51
|
+
before { subject.time = 3.seconds }
|
52
|
+
|
53
|
+
its(:time) { should == 3.seconds }
|
54
|
+
end
|
55
|
+
|
56
|
+
context "with a negative value" do
|
57
|
+
it do
|
58
|
+
lambda { subject.time = -3.seconds }.should raise_error(ArgumentError, "You must specify a valid time (positive float value in seconds)")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
context "with an invalid value" do
|
63
|
+
it do
|
64
|
+
lambda { subject.time = 'blah' }.should raise_error(ArgumentError, "You must specify a valid time (positive float value in seconds)")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "<<" do
|
70
|
+
it "should always raise InvalidChildError" do
|
71
|
+
lambda { subject << 'anything' }.should raise_error(InvalidChildError, "A Break cannot contain children")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe "comparing objects" do
|
76
|
+
it "should be equal if the content, strength and base uri are the same" do
|
77
|
+
Break.new(:strength => :strong, :time => 1.second, :content => "Hello there").should == Break.new(:strength => :strong, :time => 1.second, :content => "Hello there")
|
78
|
+
end
|
79
|
+
|
80
|
+
describe "when the content is different" do
|
81
|
+
it "should not be equal" do
|
82
|
+
Break.new(:content => "Hello").should_not == Break.new(:content => "Hello there")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe "when the strength is different" do
|
87
|
+
it "should not be equal" do
|
88
|
+
Break.new(:strength => :strong).should_not == Break.new(:strength => :weak)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "when the time is different" do
|
93
|
+
it "should not be equal" do
|
94
|
+
Break.new(:time => 1.second).should_not == Break.new(:time => 2.seconds)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end # Break
|
99
|
+
end # SSML
|
100
|
+
end # RubySpeech
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe Desc do
|
6
|
+
its(:name) { should == 'desc' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { Desc.new :language => 'foo' }
|
10
|
+
|
11
|
+
its(:language) { should == 'foo' }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'registers itself' do
|
15
|
+
Element.class_from_registration(:desc).should == Desc
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "from a document" do
|
19
|
+
let(:document) { '<desc xml:lang="en"/>' }
|
20
|
+
|
21
|
+
subject { Element.import document }
|
22
|
+
|
23
|
+
it { should be_instance_of Desc }
|
24
|
+
|
25
|
+
its(:language) { should == 'en' }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "comparing objects" do
|
29
|
+
it "should be equal if the content and language are the same" do
|
30
|
+
Desc.new(:language => 'jp', :content => "Hello there").should == Desc.new(:language => 'jp', :content => "Hello there")
|
31
|
+
end
|
32
|
+
|
33
|
+
describe "when the content is different" do
|
34
|
+
it "should not be equal" do
|
35
|
+
Desc.new(:content => "Hello").should_not == Desc.new(:content => "Hello there")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "when the language is different" do
|
40
|
+
it "should not be equal" do
|
41
|
+
Desc.new(:language => 'jp').should_not == Desc.new(:language => 'en')
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "<<" do
|
47
|
+
it "should accept String" do
|
48
|
+
lambda { subject << 'anything' }.should_not raise_error
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should raise InvalidChildError with non-acceptable objects" do
|
52
|
+
lambda { subject << Voice.new }.should raise_error(InvalidChildError, "A Desc can only accept Strings as children")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end # Desc
|
56
|
+
end # SSML
|
57
|
+
end # RubySpeech
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe Emphasis do
|
6
|
+
its(:name) { should == 'emphasis' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { Emphasis.new :level => :strong }
|
10
|
+
|
11
|
+
its(:level) { should == :strong }
|
12
|
+
end
|
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 document }
|
22
|
+
|
23
|
+
it { should be_instance_of Emphasis }
|
24
|
+
|
25
|
+
its(:level) { should == :strong }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#level" do
|
29
|
+
before { subject.level = :strong }
|
30
|
+
|
31
|
+
its(:level) { should == :strong }
|
32
|
+
|
33
|
+
it "with a valid level" do
|
34
|
+
lambda { subject.level = :strong }.should_not raise_error
|
35
|
+
lambda { subject.level = :moderate }.should_not raise_error
|
36
|
+
lambda { subject.level = :none }.should_not raise_error
|
37
|
+
lambda { subject.level = :reduced }.should_not raise_error
|
38
|
+
end
|
39
|
+
|
40
|
+
it "with an invalid level" do
|
41
|
+
lambda { subject.level = :something }.should raise_error(ArgumentError, "You must specify a valid level (:strong, :moderate, :none, :reduced)")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "comparing objects" do
|
46
|
+
it "should be equal if the content and level are the same" do
|
47
|
+
Emphasis.new(:level => :strong, :content => "Hello there").should == Emphasis.new(:level => :strong, :content => "Hello there")
|
48
|
+
end
|
49
|
+
|
50
|
+
describe "when the content is different" do
|
51
|
+
it "should not be equal" do
|
52
|
+
Emphasis.new(:content => "Hello").should_not == Emphasis.new(:content => "Hello there")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "when the level is different" do
|
57
|
+
it "should not be equal" do
|
58
|
+
Emphasis.new(:level => :strong).should_not == Emphasis.new(:level => :reduced)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe "<<" do
|
64
|
+
it "should accept String" do
|
65
|
+
lambda { subject << 'anything' }.should_not raise_error
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should accept Audio" do
|
69
|
+
lambda { subject << Audio.new }.should_not raise_error
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should accept Break" do
|
73
|
+
lambda { subject << Break.new }.should_not raise_error
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should accept Emphasis" do
|
77
|
+
lambda { subject << Emphasis.new }.should_not raise_error
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should accept Mark" do
|
81
|
+
lambda { subject << Mark.new }.should_not raise_error
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should accept Phoneme" do
|
85
|
+
lambda { subject << Phoneme.new }.should_not raise_error
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should accept Prosody" do
|
89
|
+
lambda { subject << Prosody.new }.should_not raise_error
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should accept SayAs" do
|
93
|
+
lambda { subject << SayAs.new(:interpret_as => :foo) }.should_not raise_error
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should accept Sub" do
|
97
|
+
lambda { subject << Sub.new }.should_not raise_error
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should accept Voice" do
|
101
|
+
lambda { subject << Voice.new }.should_not raise_error
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should raise InvalidChildError with non-acceptable objects" do
|
105
|
+
lambda { subject << 1 }.should raise_error(InvalidChildError, "An Emphasis can only accept String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, SayAs, Sub, Voice as children")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end # Emphasis
|
109
|
+
end # SSML
|
110
|
+
end # RubySpeech
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe Mark do
|
6
|
+
its(:node_name) { should == 'mark' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { Mark.new :name => 'foo' }
|
10
|
+
|
11
|
+
its(:name) { should == 'foo' }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'registers itself' do
|
15
|
+
Element.class_from_registration(:mark).should == Mark
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "from a document" do
|
19
|
+
let(:document) { '<mark name="foo"/>' }
|
20
|
+
|
21
|
+
subject { Element.import document }
|
22
|
+
|
23
|
+
it { should be_instance_of Mark }
|
24
|
+
|
25
|
+
its(:name) { should == 'foo' }
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#name" do
|
29
|
+
before { subject.name = 'foo' }
|
30
|
+
|
31
|
+
its(:name) { should == 'foo' }
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "<<" do
|
35
|
+
it "should always raise InvalidChildError" do
|
36
|
+
lambda { subject << 'anything' }.should raise_error(InvalidChildError, "A Mark cannot contain children")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "comparing objects" do
|
41
|
+
it "should be equal if the name is the same" do
|
42
|
+
Mark.new(:name => "foo").should == Mark.new(:name => "foo")
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "when the name is different" do
|
46
|
+
it "should not be equal" do
|
47
|
+
Mark.new(:name => "foo").should_not == Mark.new(:name => "bar")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end # Mark
|
52
|
+
end # SSML
|
53
|
+
end # RubySpeech
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe P do
|
6
|
+
its(:name) { should == 'p' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { P.new :language => 'jp' }
|
10
|
+
|
11
|
+
its(:language) { should == 'jp' }
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'registers itself' do
|
15
|
+
Element.class_from_registration(:p).should == P
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "from a document" do
|
19
|
+
let(:document) { '<p>foo</p>' }
|
20
|
+
|
21
|
+
subject { Element.import document }
|
22
|
+
|
23
|
+
it { should be_instance_of P }
|
24
|
+
its(:content) { should == 'foo' }
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "comparing objects" do
|
28
|
+
it "should be equal if the content and language are the same" do
|
29
|
+
P.new(:language => 'jp', :content => "Hello there").should == P.new(:language => 'jp', :content => "Hello there")
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "when the content is different" do
|
33
|
+
it "should not be equal" do
|
34
|
+
P.new(:content => "Hello").should_not == P.new(:content => "Hello there")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "when the language is different" do
|
39
|
+
it "should not be equal" do
|
40
|
+
P.new(:language => 'jp').should_not == P.new(:language => 'en')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "<<" do
|
46
|
+
it "should accept String" do
|
47
|
+
lambda { subject << 'anything' }.should_not raise_error
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should accept Audio" do
|
51
|
+
lambda { subject << Audio.new }.should_not raise_error
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should accept Break" do
|
55
|
+
lambda { subject << Break.new }.should_not raise_error
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should accept Emphasis" do
|
59
|
+
lambda { subject << Emphasis.new }.should_not raise_error
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should accept Mark" do
|
63
|
+
lambda { subject << Mark.new }.should_not raise_error
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should accept Phoneme" do
|
67
|
+
lambda { subject << Phoneme.new }.should_not raise_error
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should accept Prosody" do
|
71
|
+
lambda { subject << Prosody.new }.should_not raise_error
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should accept SayAs" do
|
75
|
+
lambda { subject << SayAs.new(:interpret_as => :foo) }.should_not raise_error
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should accept Sub" do
|
79
|
+
lambda { subject << Sub.new }.should_not raise_error
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should accept S" do
|
83
|
+
lambda { subject << S.new }.should_not raise_error
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should accept Voice" do
|
87
|
+
lambda { subject << Voice.new }.should_not raise_error
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should raise InvalidChildError with non-acceptable objects" do
|
91
|
+
lambda { subject << 1 }.should raise_error(InvalidChildError, "A P can only accept String, Audio, Break, Emphasis, Mark, Phoneme, Prosody, SayAs, Sub, S, Voice as children")
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end # P
|
95
|
+
end # SSML
|
96
|
+
end # RubySpeech
|
@@ -0,0 +1,65 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module RubySpeech
|
4
|
+
module SSML
|
5
|
+
describe Phoneme do
|
6
|
+
its(:name) { should == 'phoneme' }
|
7
|
+
|
8
|
+
describe "setting options in initializers" do
|
9
|
+
subject { Phoneme.new :alphabet => 'foo', :ph => 'bar' }
|
10
|
+
|
11
|
+
its(:alphabet) { should == 'foo' }
|
12
|
+
its(:ph) { should == 'bar' }
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'registers itself' do
|
16
|
+
Element.class_from_registration(:phoneme).should == Phoneme
|
17
|
+
end
|
18
|
+
|
19
|
+
describe "from a document" do
|
20
|
+
let(:document) { '<phoneme alphabet="foo" ph="bar"/>' }
|
21
|
+
|
22
|
+
subject { Element.import document }
|
23
|
+
|
24
|
+
it { should be_instance_of Phoneme }
|
25
|
+
|
26
|
+
its(:alphabet) { should == 'foo' }
|
27
|
+
its(:ph) { should == 'bar' }
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "comparing objects" do
|
31
|
+
it "should be equal if the content, ph and alphabet are the same" do
|
32
|
+
Phoneme.new(:alphabet => 'jp', :ph => 'foo', :content => "Hello there").should == Phoneme.new(:alphabet => 'jp', :ph => 'foo', :content => "Hello there")
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "when the content is different" do
|
36
|
+
it "should not be equal" do
|
37
|
+
Phoneme.new(:content => "Hello").should_not == Phoneme.new(:content => "Hello there")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "when the ph is different" do
|
42
|
+
it "should not be equal" do
|
43
|
+
Phoneme.new(:ph => 'jp').should_not == Phoneme.new(:ph => 'en')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "when the alphabet is different" do
|
48
|
+
it "should not be equal" do
|
49
|
+
Phoneme.new(:alphabet => 'jp').should_not == Phoneme.new(:alphabet => 'en')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "<<" do
|
55
|
+
it "should accept String" do
|
56
|
+
lambda { subject << 'anything' }.should_not raise_error
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should raise InvalidChildError with non-acceptable objects" do
|
60
|
+
lambda { subject << Voice.new }.should raise_error(InvalidChildError, "A Phoneme can only accept Strings as children")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end # Desc
|
64
|
+
end # SSML
|
65
|
+
end # RubySpeech
|