ruby_speech 2.3.1 → 2.3.2
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.
- checksums.yaml +4 -4
- data/.hound.yml +2 -0
- data/.travis.yml +2 -2
- data/CHANGELOG.md +6 -0
- data/README.md +4 -4
- data/lib/ruby_speech/generic_element.rb +2 -2
- data/lib/ruby_speech/nlsml/builder.rb +2 -1
- data/lib/ruby_speech/nlsml/document.rb +5 -0
- data/lib/ruby_speech/version.rb +1 -1
- data/spec/ruby_speech/grxml_spec.rb +1 -1
- data/spec/ruby_speech/nlsml_spec.rb +48 -0
- data/spec/ruby_speech/ssml_spec.rb +24 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb37334ff6ea56b3b11705f1f8091c966de69ab4
|
4
|
+
data.tar.gz: a9ef15cb9fe4fae5ae8a7b7731930d5ad7821fa7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ed551a6e78ef2e19ecf8ce194d5e1c5e04334f8974585ab7e101cbaef5bdece0c7cbb0156d721e6f682ab41170573f67a3d58eb7e0e7a7ce735d9f9d550f513
|
7
|
+
data.tar.gz: 88c7b894a74862c146256c29970b67626072f837d81bd05108ce16ab93ee338d4c17d3a7455e4e5adf2dd4bef68520d2198e73628886125c9a4e9815e55de881
|
data/.hound.yml
ADDED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# [develop](https://github.com/benlangfeld/ruby_speech)
|
2
2
|
|
3
|
+
# [2.3.2](https://github.com/benlangfeld/ruby_speech/compare/v2.3.1...v2.3.2) - [2014-04-21](https://rubygems.org/gems/ruby_speech/versions/2.3.2)
|
4
|
+
* Bugfix: String nodes should take non-strings and cast to a string (`#to_s`)
|
5
|
+
* Bugfix: Cleanly handle NLSML with no input tag
|
6
|
+
* Bugfix: Drawing an NLSML doc should return something structured/parsed
|
7
|
+
* Bugfix: Cloning SSML documents no longer turns them into GRXML docs
|
8
|
+
|
3
9
|
# [2.3.1](https://github.com/benlangfeld/ruby_speech/compare/v2.3.0...v2.3.1) - [2014-02-24](https://rubygems.org/gems/ruby_speech/versions/2.3.1)
|
4
10
|
* Bugfix: Phone number grammar should only allow a single instance of '*'/'x'
|
5
11
|
* Bugfix: Concatenating documents containing strings across the border inserts appropriate spacing (#21).
|
data/README.md
CHANGED
@@ -259,7 +259,7 @@ require 'ruby_speech'
|
|
259
259
|
|
260
260
|
nlsml = RubySpeech::NLSML.draw grammar: 'http://flight' do
|
261
261
|
interpretation confidence: 0.6 do
|
262
|
-
input "I want to go to Pittsburgh", mode: :
|
262
|
+
input "I want to go to Pittsburgh", mode: :voice
|
263
263
|
|
264
264
|
instance do
|
265
265
|
airline do
|
@@ -288,7 +288,7 @@ becomes:
|
|
288
288
|
<?xml version="1.0"?>
|
289
289
|
<result xmlns="http://www.ietf.org/xml/ns/mrcpv2" grammar="http://flight">
|
290
290
|
<interpretation confidence="0.6">
|
291
|
-
<input mode="
|
291
|
+
<input mode="voice">I want to go to Pittsburgh</input>
|
292
292
|
<instance>
|
293
293
|
<airline>
|
294
294
|
<to_city>Pittsburgh</to_city>
|
@@ -315,7 +315,7 @@ document.match? # => true
|
|
315
315
|
document.interpretations # => [
|
316
316
|
{
|
317
317
|
confidence: 0.6,
|
318
|
-
input: { mode: :
|
318
|
+
input: { mode: :voice, content: 'I want to go to Pittsburgh' },
|
319
319
|
instance: { airline: { to_city: 'Pittsburgh' } }
|
320
320
|
},
|
321
321
|
{
|
@@ -326,7 +326,7 @@ document.interpretations # => [
|
|
326
326
|
]
|
327
327
|
document.best_interpretation # => {
|
328
328
|
confidence: 0.6,
|
329
|
-
input: { mode: :
|
329
|
+
input: { mode: :voice, content: 'I want to go to Pittsburgh' },
|
330
330
|
instance: { airline: { to_city: 'Pittsburgh' } }
|
331
331
|
}
|
332
332
|
```
|
@@ -172,11 +172,11 @@ module RubySpeech
|
|
172
172
|
end
|
173
173
|
|
174
174
|
def string(other)
|
175
|
-
self << Nokogiri::XML::Text.new(other, document)
|
175
|
+
self << Nokogiri::XML::Text.new(other.to_s, document)
|
176
176
|
end
|
177
177
|
|
178
178
|
def clone
|
179
|
-
|
179
|
+
self.class.import to_xml
|
180
180
|
end
|
181
181
|
|
182
182
|
def traverse(&block)
|
@@ -5,11 +5,12 @@ module RubySpeech
|
|
5
5
|
|
6
6
|
def initialize(options = {}, &block)
|
7
7
|
options = {'xmlns' => NLSML_NAMESPACE}.merge(options)
|
8
|
-
|
8
|
+
xml_doc = Nokogiri::XML::Builder.new do |builder|
|
9
9
|
builder.result options do |r|
|
10
10
|
apply_block r, &block
|
11
11
|
end
|
12
12
|
end.doc
|
13
|
+
@document = RubySpeech::NLSML::Document.new xml_doc
|
13
14
|
end
|
14
15
|
|
15
16
|
def interpretation(*args, &block)
|
@@ -38,6 +38,10 @@ module RubySpeech
|
|
38
38
|
noinput_elements.any?
|
39
39
|
end
|
40
40
|
|
41
|
+
def to_xml
|
42
|
+
document.to_xml
|
43
|
+
end
|
44
|
+
|
41
45
|
private
|
42
46
|
|
43
47
|
def nomatch?
|
@@ -58,6 +62,7 @@ module RubySpeech
|
|
58
62
|
|
59
63
|
def input_hash_for_interpretation(interpretation)
|
60
64
|
input_element = interpretation.at_xpath 'ns:input', 'ns' => NLSML_NAMESPACE
|
65
|
+
return unless input_element
|
61
66
|
{ content: input_element.content }.tap do |h|
|
62
67
|
h[:mode] = input_element['mode'].to_sym if input_element['mode']
|
63
68
|
end
|
data/lib/ruby_speech/version.rb
CHANGED
@@ -55,6 +55,22 @@ describe RubySpeech::NLSML do
|
|
55
55
|
document.to_xml.should == expected_document
|
56
56
|
end
|
57
57
|
|
58
|
+
it "should return a structured/parsed document" do
|
59
|
+
document = RubySpeech::NLSML.draw(grammar: 'http://flight') do
|
60
|
+
interpretation confidence: 0.6 do
|
61
|
+
input "I want to go to Pittsburgh", mode: :speech
|
62
|
+
|
63
|
+
instance do
|
64
|
+
airline do
|
65
|
+
to_city 'Pittsburgh'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
document.should be_match
|
72
|
+
end
|
73
|
+
|
58
74
|
context "with a string instance" do
|
59
75
|
let :example_document do
|
60
76
|
'''
|
@@ -198,6 +214,38 @@ describe RubySpeech::NLSML do
|
|
198
214
|
its(:best_interpretation) { should == expected_best_interpretation }
|
199
215
|
end
|
200
216
|
|
217
|
+
context "with an interpretation that has no input" do
|
218
|
+
let :example_document do
|
219
|
+
'''
|
220
|
+
<result xmlns="http://www.ietf.org/xml/ns/mrcpv2" grammar="http://flight">
|
221
|
+
<interpretation confidence="0.6">
|
222
|
+
<instance>
|
223
|
+
<airline>
|
224
|
+
<to_city>Pittsburgh</to_city>
|
225
|
+
</airline>
|
226
|
+
</instance>
|
227
|
+
</interpretation>
|
228
|
+
</result>
|
229
|
+
'''
|
230
|
+
end
|
231
|
+
|
232
|
+
let(:expected_best_interpretation) do
|
233
|
+
{
|
234
|
+
confidence: 0.6,
|
235
|
+
input: nil,
|
236
|
+
instance: { airline: { to_city: 'Pittsburgh' } },
|
237
|
+
instances: [{ airline: { to_city: 'Pittsburgh' } }]
|
238
|
+
}
|
239
|
+
end
|
240
|
+
|
241
|
+
let(:expected_interpretations) do
|
242
|
+
[expected_best_interpretation]
|
243
|
+
end
|
244
|
+
|
245
|
+
its(:interpretations) { should == expected_interpretations }
|
246
|
+
its(:best_interpretation) { should == expected_best_interpretation }
|
247
|
+
end
|
248
|
+
|
201
249
|
context "with a string instance" do
|
202
250
|
let :example_document do
|
203
251
|
'''
|
@@ -81,6 +81,30 @@ module RubySpeech
|
|
81
81
|
SSML.draw { string foo }.should == expected_doc
|
82
82
|
end
|
83
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
|
+
subject.to_s.should == original.to_s
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'should match the class of the original document' do
|
99
|
+
subject.class.should == original.class
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'should be equal to the original document' do
|
103
|
+
subject.should == original
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
84
108
|
describe "embedding" do
|
85
109
|
it "SSML documents" do
|
86
110
|
doc1 = RubySpeech::SSML.draw do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_speech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Langfeld
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -207,6 +207,7 @@ extensions:
|
|
207
207
|
extra_rdoc_files: []
|
208
208
|
files:
|
209
209
|
- ".gitignore"
|
210
|
+
- ".hound.yml"
|
210
211
|
- ".rspec"
|
211
212
|
- ".travis.yml"
|
212
213
|
- CHANGELOG.md
|
@@ -316,7 +317,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
316
317
|
version: '0'
|
317
318
|
requirements: []
|
318
319
|
rubyforge_project: ruby_speech
|
319
|
-
rubygems_version: 2.2.
|
320
|
+
rubygems_version: 2.2.2
|
320
321
|
signing_key:
|
321
322
|
specification_version: 4
|
322
323
|
summary: A Ruby library for TTS & ASR document preparation
|