-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathruby_speech_spec.rb
124 lines (104 loc) · 3.24 KB
/
ruby_speech_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
require 'spec_helper'
describe RubySpeech do
describe ".parse" do
subject do
RubySpeech.parse example_document
end
context "with an SSML document" do
let :example_document do
'''<?xml version="1.0"?>
<!DOCTYPE speak PUBLIC "-//W3C//DTD SYNTHESIS 1.0//EN"
"http://www.w3.org/TR/speech-synthesis/synthesis.dtd">
<speak version="1.0"
xmlns="http://www.w3.org/2001/10/synthesis"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/10/synthesis
http://www.w3.org/TR/speech-synthesis/synthesis.xsd"
xml:lang="en-US">
<p>
<s>You have 4 new messages.</s>
<s>The first is from Stephanie Williams and arrived at <break/> 3:45pm.
</s>
<s>
The subject is <prosody rate="-20%">ski trip</prosody>
</s>
</p>
</speak>
'''
end
it { is_expected.to be_a RubySpeech::SSML::Element }
end
context "with a GRXML document" do
let :example_document do
'''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN"
"http://www.w3.org/TR/speech-grammar/grammar.dtd">
<grammar xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/06/grammar
http://www.w3.org/TR/speech-grammar/grammar.xsd"
version="1.0" mode="voice" root="basicCmd">
<meta name="author" content="Stephanie Williams"/>
<rule id="basicCmd" scope="public">
<example> please move the window </example>
<example> open a file </example>
<ruleref uri="http://grammar.example.com/politeness.grxml#startPolite"/>
<ruleref uri="#command"/>
<ruleref uri="http://grammar.example.com/politeness.grxml#endPolite"/>
</rule>
<rule id="command">
<ruleref uri="#action"/> <ruleref uri="#object"/>
</rule>
<rule id="action">
<one-of>
<item weight="10"> open <tag>TAG-CONTENT-1</tag> </item>
<item weight="2"> close <tag>TAG-CONTENT-2</tag> </item>
<item weight="1"> delete <tag>TAG-CONTENT-3</tag> </item>
<item weight="1"> move <tag>TAG-CONTENT-4</tag> </item>
</one-of>
</rule>
<rule id="object">
<item repeat="0-1">
<one-of>
<item> the </item>
<item> a </item>
</one-of>
</item>
<one-of>
<item> window </item>
<item> file </item>
<item> menu </item>
</one-of>
</rule>
</grammar>
'''
end
it { is_expected.to be_a RubySpeech::GRXML::Element }
end
context "with an NLSML document" do
let :example_document do
'''
<result xmlns="http://www.ietf.org/xml/ns/mrcpv2" grammar="http://flight">
<interpretation confidence="60">
<input mode="speech">I want to go to Pittsburgh</input>
<instance>
<airline>
<to_city>Pittsburgh</to_city>
</airline>
</instance>
</interpretation>
<interpretation confidence="40">
<input>I want to go to Stockholm</input>
<instance>
<airline>
<to_city>Stockholm</to_city>
</airline>
</instance>
</interpretation>
</result>
'''
end
it { is_expected.to be_a RubySpeech::NLSML::Document }
end
end
end