ruby_speech 2.3.1-java → 3.0.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.hound.yml +2 -0
- data/.travis.yml +25 -9
- data/CHANGELOG.md +19 -1
- data/README.md +14 -15
- data/Rakefile +2 -0
- data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +17 -12
- data/ext/ruby_speech/RubySpeechService.java +1 -1
- data/ext/ruby_speech/extconf.rb +1 -1
- data/lib/ruby_speech/generic_element.rb +2 -2
- data/lib/ruby_speech/grxml/builtins.rb +18 -11
- data/lib/ruby_speech/grxml/grammar.rb +26 -4
- data/lib/ruby_speech/grxml/matcher.rb +2 -2
- data/lib/ruby_speech/grxml.rb +2 -0
- data/lib/ruby_speech/nlsml/builder.rb +2 -1
- data/lib/ruby_speech/nlsml/document.rb +5 -0
- data/lib/ruby_speech/ruby_speech.jar +0 -0
- data/lib/ruby_speech/ssml/break.rb +1 -2
- data/lib/ruby_speech/ssml/element.rb +13 -1
- data/lib/ruby_speech/ssml/mark.rb +0 -1
- data/lib/ruby_speech/ssml/prosody.rb +8 -5
- data/lib/ruby_speech/version.rb +1 -1
- data/ruby_speech.gemspec +13 -8
- data/spec/ruby_speech/grxml/builtins_spec.rb +80 -71
- data/spec/ruby_speech/grxml/grammar_spec.rb +168 -34
- data/spec/ruby_speech/grxml/item_spec.rb +33 -33
- data/spec/ruby_speech/grxml/match_spec.rb +1 -1
- data/spec/ruby_speech/grxml/matcher_spec.rb +103 -59
- data/spec/ruby_speech/grxml/max_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/no_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/one_of_spec.rb +6 -6
- data/spec/ruby_speech/grxml/potential_match_spec.rb +2 -2
- data/spec/ruby_speech/grxml/rule_spec.rb +17 -17
- data/spec/ruby_speech/grxml/ruleref_spec.rb +10 -10
- data/spec/ruby_speech/grxml/tag_spec.rb +5 -5
- data/spec/ruby_speech/grxml/token_spec.rb +7 -7
- data/spec/ruby_speech/grxml_spec.rb +25 -25
- data/spec/ruby_speech/nlsml_spec.rb +58 -10
- data/spec/ruby_speech/ssml/audio_spec.rb +19 -19
- data/spec/ruby_speech/ssml/break_spec.rb +42 -22
- data/spec/ruby_speech/ssml/desc_spec.rb +7 -7
- data/spec/ruby_speech/ssml/emphasis_spec.rb +21 -21
- data/spec/ruby_speech/ssml/mark_spec.rb +5 -5
- data/spec/ruby_speech/ssml/p_spec.rb +17 -17
- data/spec/ruby_speech/ssml/phoneme_spec.rb +8 -8
- data/spec/ruby_speech/ssml/prosody_spec.rb +82 -64
- data/spec/ruby_speech/ssml/s_spec.rb +16 -16
- data/spec/ruby_speech/ssml/say_as_spec.rb +9 -9
- data/spec/ruby_speech/ssml/speak_spec.rb +29 -29
- data/spec/ruby_speech/ssml/sub_spec.rb +7 -7
- data/spec/ruby_speech/ssml/voice_spec.rb +31 -31
- data/spec/ruby_speech/ssml_spec.rb +41 -17
- data/spec/ruby_speech_spec.rb +3 -3
- data/spec/spec_helper.rb +8 -3
- data/spec/support/dtmf_helper.rb +14 -0
- data/spec/support/grammar_matchers.rb +6 -6
- data/spec/support/match_examples.rb +5 -5
- data/spec/support/matchers.rb +1 -1
- metadata +109 -80
@@ -7,7 +7,7 @@ module RubySpeech
|
|
7
7
|
|
8
8
|
subject { described_class.new doc }
|
9
9
|
|
10
|
-
it {
|
10
|
+
it { is_expected.to be_a_valid_ssml_document }
|
11
11
|
|
12
12
|
its(:name) { should == 'speak' }
|
13
13
|
its(:language) { should == 'en-US' }
|
@@ -20,7 +20,7 @@ module RubySpeech
|
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'registers itself' do
|
23
|
-
Element.class_from_registration(:speak).
|
23
|
+
expect(Element.class_from_registration(:speak)).to eq(Speak)
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "from a document" do
|
@@ -28,7 +28,7 @@ module RubySpeech
|
|
28
28
|
|
29
29
|
subject { Element.import document }
|
30
30
|
|
31
|
-
it {
|
31
|
+
it { is_expected.to be_instance_of Speak }
|
32
32
|
|
33
33
|
its(:language) { should == 'jp' }
|
34
34
|
its(:base_uri) { should == 'blah' }
|
@@ -48,24 +48,24 @@ module RubySpeech
|
|
48
48
|
|
49
49
|
describe "comparing objects" do
|
50
50
|
it "should be equal if the content, language and base uri are the same" do
|
51
|
-
Speak.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there").
|
51
|
+
expect(Speak.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there")).to eq(Speak.new(doc, :language => 'en-GB', :base_uri => 'blah', :content => "Hello there"))
|
52
52
|
end
|
53
53
|
|
54
54
|
describe "when the content is different" do
|
55
55
|
it "should not be equal" do
|
56
|
-
Speak.new(doc, :content => "Hello").
|
56
|
+
expect(Speak.new(doc, :content => "Hello")).not_to eq(Speak.new(doc, :content => "Hello there"))
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
60
|
describe "when the language is different" do
|
61
61
|
it "should not be equal" do
|
62
|
-
Speak.new(doc, :language => 'en-US').
|
62
|
+
expect(Speak.new(doc, :language => 'en-US')).not_to eq(Speak.new(doc, :language => 'en-GB'))
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
66
|
describe "when the base URI is different" do
|
67
67
|
it "should not be equal" do
|
68
|
-
Speak.new(doc, :base_uri => 'foo').
|
68
|
+
expect(Speak.new(doc, :base_uri => 'foo')).not_to eq(Speak.new(doc, :base_uri => 'bar'))
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
@@ -76,7 +76,7 @@ module RubySpeech
|
|
76
76
|
s2 = Speak.new doc
|
77
77
|
s2 << SayAs.new(doc, :interpret_as => 'time')
|
78
78
|
|
79
|
-
s1.
|
79
|
+
expect(s1).not_to eq(s2)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -86,66 +86,66 @@ module RubySpeech
|
|
86
86
|
s.voice :gender => :male, :content => 'Hello'
|
87
87
|
expected_s = Speak.new doc
|
88
88
|
expected_s << Voice.new(doc, :gender => :male, :content => 'Hello')
|
89
|
-
s.
|
89
|
+
expect(s).to eq(expected_s)
|
90
90
|
end
|
91
91
|
|
92
92
|
describe "<<" do
|
93
93
|
it "should accept String" do
|
94
|
-
|
94
|
+
expect { subject << 'anything' }.not_to raise_error
|
95
95
|
end
|
96
96
|
|
97
97
|
it "should accept Audio" do
|
98
|
-
|
98
|
+
expect { subject << Audio.new(doc) }.not_to raise_error
|
99
99
|
end
|
100
100
|
|
101
101
|
it "should accept Break" do
|
102
|
-
|
102
|
+
expect { subject << Break.new(doc) }.not_to raise_error
|
103
103
|
end
|
104
104
|
|
105
105
|
it "should accept Emphasis" do
|
106
|
-
|
106
|
+
expect { subject << Emphasis.new(doc) }.not_to raise_error
|
107
107
|
end
|
108
108
|
|
109
109
|
it "should accept Mark" do
|
110
|
-
|
110
|
+
expect { subject << Mark.new(doc) }.not_to raise_error
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should accept P" do
|
114
|
-
|
114
|
+
expect { subject << P.new(doc) }.not_to raise_error
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should accept Phoneme" do
|
118
|
-
|
118
|
+
expect { subject << Phoneme.new(doc) }.not_to raise_error
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should accept Prosody" do
|
122
|
-
|
122
|
+
expect { subject << Prosody.new(doc) }.not_to raise_error
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should accept SayAs" do
|
126
|
-
|
126
|
+
expect { subject << SayAs.new(doc, :interpret_as => :foo) }.not_to raise_error
|
127
127
|
end
|
128
128
|
|
129
129
|
it "should accept Sub" do
|
130
|
-
|
130
|
+
expect { subject << Sub.new(doc) }.not_to raise_error
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should accept S" do
|
134
|
-
|
134
|
+
expect { subject << S.new(doc) }.not_to raise_error
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should accept Voice" do
|
138
|
-
|
138
|
+
expect { subject << Voice.new(doc) }.not_to raise_error
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should raise InvalidChildError with non-acceptable objects" do
|
142
|
-
|
142
|
+
expect { subject << 1 }.to raise_error(InvalidChildError, "A Speak can only accept String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, SayAs, Sub, S, Voice as children")
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
146
|
describe "#to_doc" do
|
147
147
|
it "should create an XML document from the grammar" do
|
148
|
-
subject.to_doc.
|
148
|
+
expect(subject.to_doc).to eq(subject.document)
|
149
149
|
end
|
150
150
|
end
|
151
151
|
|
@@ -176,11 +176,11 @@ module RubySpeech
|
|
176
176
|
end
|
177
177
|
|
178
178
|
concat = (speak1 + speak2)
|
179
|
-
speak1.to_s.
|
180
|
-
speak2.to_s.
|
181
|
-
concat.
|
182
|
-
concat.document.root.
|
183
|
-
concat.to_s.
|
179
|
+
expect(speak1.to_s).to eq(speak1_string)
|
180
|
+
expect(speak2.to_s).to eq(speak2_string)
|
181
|
+
expect(concat).to eq(expected_concat)
|
182
|
+
expect(concat.document.root).to eq(concat)
|
183
|
+
expect(concat.to_s).not_to include('default')
|
184
184
|
end
|
185
185
|
|
186
186
|
context "when concatenating" do
|
@@ -199,7 +199,7 @@ module RubySpeech
|
|
199
199
|
end
|
200
200
|
|
201
201
|
concat = (speak1 + speak2)
|
202
|
-
concat.
|
202
|
+
expect(concat).to eq(expected_concat)
|
203
203
|
end
|
204
204
|
end
|
205
205
|
end
|
@@ -16,7 +16,7 @@ module RubySpeech
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'registers itself' do
|
19
|
-
Element.class_from_registration(:sub).
|
19
|
+
expect(Element.class_from_registration(:sub)).to eq(Sub)
|
20
20
|
end
|
21
21
|
|
22
22
|
describe "from a document" do
|
@@ -24,36 +24,36 @@ module RubySpeech
|
|
24
24
|
|
25
25
|
subject { Element.import document }
|
26
26
|
|
27
|
-
it {
|
27
|
+
it { is_expected.to be_instance_of Sub }
|
28
28
|
|
29
29
|
its(:alias) { should == 'foo' }
|
30
30
|
end
|
31
31
|
|
32
32
|
describe "comparing objects" do
|
33
33
|
it "should be equal if the content and alias are the same" do
|
34
|
-
Sub.new(doc, :alias => 'jp', :content => "Hello there").
|
34
|
+
expect(Sub.new(doc, :alias => 'jp', :content => "Hello there")).to eq(Sub.new(doc, :alias => 'jp', :content => "Hello there"))
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "when the content is different" do
|
38
38
|
it "should not be equal" do
|
39
|
-
Sub.new(doc, :content => "Hello").
|
39
|
+
expect(Sub.new(doc, :content => "Hello")).not_to eq(Sub.new(doc, :content => "Hello there"))
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe "when the alias is different" do
|
44
44
|
it "should not be equal" do
|
45
|
-
Sub.new(doc, :alias => 'jp').
|
45
|
+
expect(Sub.new(doc, :alias => 'jp')).not_to eq(Sub.new(doc, :alias => 'en'))
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
49
49
|
|
50
50
|
describe "<<" do
|
51
51
|
it "should accept String" do
|
52
|
-
|
52
|
+
expect { subject << 'anything' }.not_to raise_error
|
53
53
|
end
|
54
54
|
|
55
55
|
it "should raise InvalidChildError with non-acceptable objects" do
|
56
|
-
|
56
|
+
expect { subject << Voice.new(doc) }.to raise_error(InvalidChildError, "A Sub can only accept Strings as children")
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end # Desc
|
@@ -21,7 +21,7 @@ module RubySpeech
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it 'registers itself' do
|
24
|
-
Element.class_from_registration(:voice).
|
24
|
+
expect(Element.class_from_registration(:voice)).to eq(Voice)
|
25
25
|
end
|
26
26
|
|
27
27
|
describe "from a document" do
|
@@ -29,7 +29,7 @@ module RubySpeech
|
|
29
29
|
|
30
30
|
subject { Element.import document }
|
31
31
|
|
32
|
-
it {
|
32
|
+
it { is_expected.to be_instance_of Voice }
|
33
33
|
|
34
34
|
its(:language) { should == 'jp' }
|
35
35
|
its(:gender) { should == :male }
|
@@ -50,13 +50,13 @@ module RubySpeech
|
|
50
50
|
its(:gender) { should == :male }
|
51
51
|
|
52
52
|
it "with a valid gender" do
|
53
|
-
|
54
|
-
|
55
|
-
|
53
|
+
expect { subject.gender = :male }.not_to raise_error
|
54
|
+
expect { subject.gender = :female }.not_to raise_error
|
55
|
+
expect { subject.gender = :neutral }.not_to raise_error
|
56
56
|
end
|
57
57
|
|
58
58
|
it "with an invalid gender" do
|
59
|
-
|
59
|
+
expect { subject.gender = :something }.to raise_error(ArgumentError, "You must specify a valid gender (:male, :female, :neutral)")
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -66,15 +66,15 @@ module RubySpeech
|
|
66
66
|
its(:age) { should == 12 }
|
67
67
|
|
68
68
|
it "with an integer of 0" do
|
69
|
-
|
69
|
+
expect { subject.age = 0 }.not_to raise_error
|
70
70
|
end
|
71
71
|
|
72
72
|
it "with an integer less than 0" do
|
73
|
-
|
73
|
+
expect { subject.age = -1 }.to raise_error(ArgumentError, "You must specify a valid age (non-negative integer)")
|
74
74
|
end
|
75
75
|
|
76
76
|
it "with something other than an integer" do
|
77
|
-
|
77
|
+
expect { subject.age = "bah" }.to raise_error(ArgumentError, "You must specify a valid age (non-negative integer)")
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -84,11 +84,11 @@ module RubySpeech
|
|
84
84
|
its(:variant) { should == 12 }
|
85
85
|
|
86
86
|
it "with an integer less than 1" do
|
87
|
-
|
87
|
+
expect { subject.variant = 0 }.to raise_error(ArgumentError, "You must specify a valid variant (positive integer)")
|
88
88
|
end
|
89
89
|
|
90
90
|
it "with something other than an integer" do
|
91
|
-
|
91
|
+
expect { subject.variant = "bah" }.to raise_error(ArgumentError, "You must specify a valid variant (positive integer)")
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -106,97 +106,97 @@ module RubySpeech
|
|
106
106
|
|
107
107
|
describe "comparing objects" do
|
108
108
|
it "should be equal if the content, language, gender, age, variant, name are the same" do
|
109
|
-
Voice.new(doc, :language => 'jp', :gender => :male, :age => 25, :variant => 2, :name => "paul", :content => "hello").
|
109
|
+
expect(Voice.new(doc, :language => 'jp', :gender => :male, :age => 25, :variant => 2, :name => "paul", :content => "hello")).to eq(Voice.new(doc, :language => 'jp', :gender => :male, :age => 25, :variant => 2, :name => "paul", :content => "hello"))
|
110
110
|
end
|
111
111
|
|
112
112
|
describe "when the content is different" do
|
113
113
|
it "should not be equal" do
|
114
|
-
Voice.new(doc, :content => "Hello").
|
114
|
+
expect(Voice.new(doc, :content => "Hello")).not_to eq(Voice.new(doc, :content => "Hello there"))
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe "when the language is different" do
|
119
119
|
it "should not be equal" do
|
120
|
-
Voice.new(doc, :language => "Hello").
|
120
|
+
expect(Voice.new(doc, :language => "Hello")).not_to eq(Voice.new(doc, :language => "Hello there"))
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
124
|
describe "when the gender is different" do
|
125
125
|
it "should not be equal" do
|
126
|
-
Voice.new(doc, :gender => :male).
|
126
|
+
expect(Voice.new(doc, :gender => :male)).not_to eq(Voice.new(doc, :gender => :female))
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
describe "when the age is different" do
|
131
131
|
it "should not be equal" do
|
132
|
-
Voice.new(doc, :age => 20).
|
132
|
+
expect(Voice.new(doc, :age => 20)).not_to eq(Voice.new(doc, :age => 30))
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
136
|
describe "when the variant is different" do
|
137
137
|
it "should not be equal" do
|
138
|
-
Voice.new(doc, :variant => 1).
|
138
|
+
expect(Voice.new(doc, :variant => 1)).not_to eq(Voice.new(doc, :variant => 2))
|
139
139
|
end
|
140
140
|
end
|
141
141
|
|
142
142
|
describe "when the name is different" do
|
143
143
|
it "should not be equal" do
|
144
|
-
Voice.new(doc, :name => "Hello").
|
144
|
+
expect(Voice.new(doc, :name => "Hello")).not_to eq(Voice.new(doc, :name => "Hello there"))
|
145
145
|
end
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
149
149
|
describe "<<" do
|
150
150
|
it "should accept String" do
|
151
|
-
|
151
|
+
expect { subject << 'anything' }.not_to raise_error
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should accept Audio" do
|
155
|
-
|
155
|
+
expect { subject << Audio.new(doc) }.not_to raise_error
|
156
156
|
end
|
157
157
|
|
158
158
|
it "should accept Break" do
|
159
|
-
|
159
|
+
expect { subject << Break.new(doc) }.not_to raise_error
|
160
160
|
end
|
161
161
|
|
162
162
|
it "should accept Emphasis" do
|
163
|
-
|
163
|
+
expect { subject << Emphasis.new(doc) }.not_to raise_error
|
164
164
|
end
|
165
165
|
|
166
166
|
it "should accept Mark" do
|
167
|
-
|
167
|
+
expect { subject << Mark.new(doc) }.not_to raise_error
|
168
168
|
end
|
169
169
|
|
170
170
|
it "should accept P" do
|
171
|
-
|
171
|
+
expect { subject << P.new(doc) }.not_to raise_error
|
172
172
|
end
|
173
173
|
|
174
174
|
it "should accept Phoneme" do
|
175
|
-
|
175
|
+
expect { subject << Phoneme.new(doc) }.not_to raise_error
|
176
176
|
end
|
177
177
|
|
178
178
|
it "should accept Prosody" do
|
179
|
-
|
179
|
+
expect { subject << Prosody.new(doc) }.not_to raise_error
|
180
180
|
end
|
181
181
|
|
182
182
|
it "should accept SayAs" do
|
183
|
-
|
183
|
+
expect { subject << SayAs.new(doc, :interpret_as => :foo) }.not_to raise_error
|
184
184
|
end
|
185
185
|
|
186
186
|
it "should accept Sub" do
|
187
|
-
|
187
|
+
expect { subject << Sub.new(doc) }.not_to raise_error
|
188
188
|
end
|
189
189
|
|
190
190
|
it "should accept S" do
|
191
|
-
|
191
|
+
expect { subject << S.new(doc) }.not_to raise_error
|
192
192
|
end
|
193
193
|
|
194
194
|
it "should accept Voice" do
|
195
|
-
|
195
|
+
expect { subject << Voice.new(doc) }.not_to raise_error
|
196
196
|
end
|
197
197
|
|
198
198
|
it "should raise InvalidChildError with non-acceptable objects" do
|
199
|
-
|
199
|
+
expect { subject << 1 }.to raise_error(InvalidChildError, "A Voice can only accept String, Audio, Break, Emphasis, Mark, P, Phoneme, Prosody, SayAs, Sub, S, Voice as children")
|
200
200
|
end
|
201
201
|
end
|
202
202
|
end # Voice
|
@@ -7,40 +7,40 @@ module RubySpeech
|
|
7
7
|
|
8
8
|
it "should create an SSML document" do
|
9
9
|
expected_doc = SSML::Speak.new doc
|
10
|
-
SSML.draw.
|
11
|
-
SSML.draw.document.xpath('ns:speak', ns: 'http://www.w3.org/2001/10/synthesis').size.
|
10
|
+
expect(SSML.draw).to eq(expected_doc)
|
11
|
+
expect(SSML.draw.document.xpath('ns:speak', ns: 'http://www.w3.org/2001/10/synthesis').size).to eq(1)
|
12
12
|
end
|
13
13
|
|
14
14
|
it "can draw with a language" do
|
15
15
|
expected_doc = SSML::Speak.new doc, language: 'pt-BR'
|
16
|
-
SSML.draw(language: 'pt-BR').
|
16
|
+
expect(SSML.draw(language: 'pt-BR')).to eq(expected_doc)
|
17
17
|
end
|
18
18
|
|
19
19
|
describe "when the return value of the block is a string" do
|
20
20
|
it "should be inserted into the document" do
|
21
21
|
expected_doc = SSML::Speak.new(doc, :content => "Hi, I'm Fred")
|
22
|
-
SSML.draw { "Hi, I'm Fred" }.
|
22
|
+
expect(SSML.draw { "Hi, I'm Fred" }).to eq(expected_doc)
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "when the return value of the block is not a string" do
|
27
27
|
it "should not be inserted into the document" do
|
28
28
|
expected_doc = SSML::Speak.new doc
|
29
|
-
SSML.draw { :foo }.
|
29
|
+
expect(SSML.draw { :foo }).to eq(expected_doc)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
33
|
describe "when inserting a string" do
|
34
34
|
it "should work" do
|
35
35
|
expected_doc = SSML::Speak.new(doc, :content => "Hi, I'm Fred")
|
36
|
-
SSML.draw { string "Hi, I'm Fred" }.
|
36
|
+
expect(SSML.draw { string "Hi, I'm Fred" }).to eq(expected_doc)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should allow other SSML elements to be inserted in the document" do
|
41
41
|
expected_doc = SSML::Speak.new doc
|
42
42
|
expected_doc << SSML::Voice.new(doc, :gender => :male, :name => 'fred')
|
43
|
-
SSML.draw { voice :gender => :male, :name => 'fred' }.
|
43
|
+
expect(SSML.draw { voice :gender => :male, :name => 'fred' }).to eq(expected_doc)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should allow nested block return values" do
|
@@ -52,7 +52,7 @@ module RubySpeech
|
|
52
52
|
"Hi, I'm Fred."
|
53
53
|
end
|
54
54
|
end
|
55
|
-
doc.
|
55
|
+
expect(doc).to eq(expected_doc)
|
56
56
|
end
|
57
57
|
|
58
58
|
it "should allow nested SSML elements" do
|
@@ -69,7 +69,7 @@ module RubySpeech
|
|
69
69
|
voice << SSML::SayAs.new(doc, :interpret_as => 'date', :format => 'dmy', :content => "01/02/1960")
|
70
70
|
expected_doc = SSML::Speak.new doc
|
71
71
|
expected_doc << voice
|
72
|
-
drawn_doc.
|
72
|
+
expect(drawn_doc).to eq(expected_doc)
|
73
73
|
end
|
74
74
|
|
75
75
|
it "should allow accessing methods defined outside the block" do
|
@@ -78,7 +78,31 @@ module RubySpeech
|
|
78
78
|
end
|
79
79
|
|
80
80
|
expected_doc = SSML::Speak.new doc, :content => foo
|
81
|
-
SSML.draw { string foo }.
|
81
|
+
expect(SSML.draw { string foo }).to eq(expected_doc)
|
82
|
+
end
|
83
|
+
|
84
|
+
describe 'cloning' do
|
85
|
+
context 'SSML documents' do
|
86
|
+
let :original do
|
87
|
+
RubySpeech::SSML.draw do
|
88
|
+
string "Hi, I'm Fred."
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
subject { original.clone }
|
93
|
+
|
94
|
+
it 'should match the contents of the original document' do
|
95
|
+
expect(subject.to_s).to eq(original.to_s)
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should match the class of the original document' do
|
99
|
+
expect(subject.class).to eq(original.class)
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should be equal to the original document' do
|
103
|
+
expect(subject).to eq(original)
|
104
|
+
end
|
105
|
+
end
|
82
106
|
end
|
83
107
|
|
84
108
|
describe "embedding" do
|
@@ -105,7 +129,7 @@ module RubySpeech
|
|
105
129
|
end
|
106
130
|
end
|
107
131
|
|
108
|
-
doc2.
|
132
|
+
expect(doc2).to eq(expected_doc)
|
109
133
|
end
|
110
134
|
|
111
135
|
it "SSML elements" do
|
@@ -125,7 +149,7 @@ module RubySpeech
|
|
125
149
|
end
|
126
150
|
end
|
127
151
|
|
128
|
-
doc.
|
152
|
+
expect(doc).to eq(expected_doc)
|
129
153
|
end
|
130
154
|
|
131
155
|
it "strings" do
|
@@ -143,7 +167,7 @@ module RubySpeech
|
|
143
167
|
end
|
144
168
|
end
|
145
169
|
|
146
|
-
doc.
|
170
|
+
expect(doc).to eq(expected_doc)
|
147
171
|
end
|
148
172
|
end
|
149
173
|
|
@@ -156,7 +180,7 @@ module RubySpeech
|
|
156
180
|
2.times do
|
157
181
|
expected_doc << SSML::Voice.new(doc, :native_content => "I <3 nachos.")
|
158
182
|
end
|
159
|
-
drawn_doc.
|
183
|
+
expect(drawn_doc).to eq(expected_doc)
|
160
184
|
end
|
161
185
|
|
162
186
|
it "should allow all permutations of possible nested SSML elements" do
|
@@ -246,7 +270,7 @@ module RubySpeech
|
|
246
270
|
voice << SSML::Prosody.new(doc, :rate => :fast, :content => "And yet so spritely!")
|
247
271
|
voice << SSML::Voice.new(doc, :age => 12, :content => "And I'm young Fred")
|
248
272
|
expected_doc << voice
|
249
|
-
drawn_doc.
|
273
|
+
expect(drawn_doc).to eq(expected_doc)
|
250
274
|
end
|
251
275
|
end
|
252
276
|
|
@@ -269,10 +293,10 @@ module RubySpeech
|
|
269
293
|
subject { import }
|
270
294
|
|
271
295
|
it "should work" do
|
272
|
-
|
296
|
+
expect { subject }.not_to raise_error
|
273
297
|
end
|
274
298
|
|
275
|
-
it {
|
299
|
+
it { is_expected.to be_a SSML::Speak }
|
276
300
|
|
277
301
|
its(:children) { should == [voice] }
|
278
302
|
|
data/spec/ruby_speech_spec.rb
CHANGED
@@ -30,7 +30,7 @@ describe RubySpeech do
|
|
30
30
|
'''
|
31
31
|
end
|
32
32
|
|
33
|
-
it {
|
33
|
+
it { is_expected.to be_a RubySpeech::SSML::Element }
|
34
34
|
end
|
35
35
|
|
36
36
|
context "with a GRXML document" do
|
@@ -91,7 +91,7 @@ describe RubySpeech do
|
|
91
91
|
'''
|
92
92
|
end
|
93
93
|
|
94
|
-
it {
|
94
|
+
it { is_expected.to be_a RubySpeech::GRXML::Element }
|
95
95
|
end
|
96
96
|
|
97
97
|
context "with an NLSML document" do
|
@@ -118,7 +118,7 @@ describe RubySpeech do
|
|
118
118
|
'''
|
119
119
|
end
|
120
120
|
|
121
|
-
it {
|
121
|
+
it { is_expected.to be_a RubySpeech::NLSML::Document }
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
+
require "coveralls"
|
4
5
|
Coveralls.wear!
|
5
6
|
|
7
|
+
%w{
|
8
|
+
rspec/its
|
9
|
+
ruby_speech
|
10
|
+
}.each { |f| require f }
|
11
|
+
|
6
12
|
Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
|
7
13
|
|
8
14
|
schema_file_path = File.expand_path File.join(__FILE__, '../../assets/synthesis.xsd')
|
@@ -18,5 +24,4 @@ puts "Finished loading schema."
|
|
18
24
|
RSpec.configure do |config|
|
19
25
|
config.filter_run :focus => true
|
20
26
|
config.run_all_when_everything_filtered = true
|
21
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
22
27
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# Convert a simple DTMF string from "1 star 2" to "dtmf-1 dtmf-star dtmf-2".
|
6
|
+
#
|
7
|
+
# @param [Array] sequence A set of DTMF keys, such as `%w(1 star 2)`.
|
8
|
+
#
|
9
|
+
# @return [String] A string with "dtmf-" prefixed for each DTMF element.
|
10
|
+
# Example: "dtmf-1 dtmf-star dtmf-2".
|
11
|
+
#
|
12
|
+
def dtmf_seq(sequence)
|
13
|
+
sequence.map { |d| "dtmf-#{d}" }.join ' '
|
14
|
+
end
|