ruby_speech 2.1.0-java

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.
Files changed (90) hide show
  1. data/.gitignore +12 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +17 -0
  4. data/CHANGELOG.md +144 -0
  5. data/Gemfile +3 -0
  6. data/Guardfile +9 -0
  7. data/LICENSE.md +20 -0
  8. data/README.md +314 -0
  9. data/Rakefile +34 -0
  10. data/assets/grammar-core.xsd +317 -0
  11. data/assets/grammar.xsd +37 -0
  12. data/assets/synthesis-core.xsd +445 -0
  13. data/assets/synthesis.xsd +63 -0
  14. data/assets/xml.xsd +287 -0
  15. data/ext/ruby_speech/RubySpeechGRXMLMatcher.java +64 -0
  16. data/ext/ruby_speech/RubySpeechService.java +23 -0
  17. data/ext/ruby_speech/extconf.rb +7 -0
  18. data/ext/ruby_speech/ruby_speech.c +97 -0
  19. data/lib/ruby_speech/generic_element.rb +169 -0
  20. data/lib/ruby_speech/grxml/element.rb +29 -0
  21. data/lib/ruby_speech/grxml/grammar.rb +189 -0
  22. data/lib/ruby_speech/grxml/item.rb +144 -0
  23. data/lib/ruby_speech/grxml/match.rb +16 -0
  24. data/lib/ruby_speech/grxml/matcher.rb +126 -0
  25. data/lib/ruby_speech/grxml/max_match.rb +6 -0
  26. data/lib/ruby_speech/grxml/no_match.rb +10 -0
  27. data/lib/ruby_speech/grxml/one_of.rb +31 -0
  28. data/lib/ruby_speech/grxml/potential_match.rb +10 -0
  29. data/lib/ruby_speech/grxml/rule.rb +73 -0
  30. data/lib/ruby_speech/grxml/ruleref.rb +69 -0
  31. data/lib/ruby_speech/grxml/tag.rb +29 -0
  32. data/lib/ruby_speech/grxml/token.rb +31 -0
  33. data/lib/ruby_speech/grxml.rb +39 -0
  34. data/lib/ruby_speech/nlsml/builder.rb +34 -0
  35. data/lib/ruby_speech/nlsml/document.rb +120 -0
  36. data/lib/ruby_speech/nlsml.rb +18 -0
  37. data/lib/ruby_speech/ruby_speech.jar +0 -0
  38. data/lib/ruby_speech/ssml/audio.rb +47 -0
  39. data/lib/ruby_speech/ssml/break.rb +62 -0
  40. data/lib/ruby_speech/ssml/desc.rb +24 -0
  41. data/lib/ruby_speech/ssml/element.rb +23 -0
  42. data/lib/ruby_speech/ssml/emphasis.rb +44 -0
  43. data/lib/ruby_speech/ssml/mark.rb +43 -0
  44. data/lib/ruby_speech/ssml/p.rb +25 -0
  45. data/lib/ruby_speech/ssml/phoneme.rb +72 -0
  46. data/lib/ruby_speech/ssml/prosody.rb +172 -0
  47. data/lib/ruby_speech/ssml/s.rb +25 -0
  48. data/lib/ruby_speech/ssml/say_as.rb +100 -0
  49. data/lib/ruby_speech/ssml/speak.rb +27 -0
  50. data/lib/ruby_speech/ssml/sub.rb +42 -0
  51. data/lib/ruby_speech/ssml/voice.rb +108 -0
  52. data/lib/ruby_speech/ssml.rb +39 -0
  53. data/lib/ruby_speech/version.rb +3 -0
  54. data/lib/ruby_speech/xml/language.rb +13 -0
  55. data/lib/ruby_speech/xml.rb +11 -0
  56. data/lib/ruby_speech.rb +36 -0
  57. data/ruby_speech.gemspec +42 -0
  58. data/spec/ruby_speech/grxml/grammar_spec.rb +341 -0
  59. data/spec/ruby_speech/grxml/item_spec.rb +192 -0
  60. data/spec/ruby_speech/grxml/match_spec.rb +15 -0
  61. data/spec/ruby_speech/grxml/matcher_spec.rb +688 -0
  62. data/spec/ruby_speech/grxml/max_match_spec.rb +17 -0
  63. data/spec/ruby_speech/grxml/no_match_spec.rb +17 -0
  64. data/spec/ruby_speech/grxml/one_of_spec.rb +49 -0
  65. data/spec/ruby_speech/grxml/potential_match_spec.rb +17 -0
  66. data/spec/ruby_speech/grxml/rule_spec.rb +125 -0
  67. data/spec/ruby_speech/grxml/ruleref_spec.rb +55 -0
  68. data/spec/ruby_speech/grxml/tag_spec.rb +41 -0
  69. data/spec/ruby_speech/grxml/token_spec.rb +62 -0
  70. data/spec/ruby_speech/grxml_spec.rb +339 -0
  71. data/spec/ruby_speech/nlsml_spec.rb +353 -0
  72. data/spec/ruby_speech/ssml/audio_spec.rb +121 -0
  73. data/spec/ruby_speech/ssml/break_spec.rb +100 -0
  74. data/spec/ruby_speech/ssml/desc_spec.rb +57 -0
  75. data/spec/ruby_speech/ssml/emphasis_spec.rb +110 -0
  76. data/spec/ruby_speech/ssml/mark_spec.rb +53 -0
  77. data/spec/ruby_speech/ssml/p_spec.rb +96 -0
  78. data/spec/ruby_speech/ssml/phoneme_spec.rb +65 -0
  79. data/spec/ruby_speech/ssml/prosody_spec.rb +309 -0
  80. data/spec/ruby_speech/ssml/s_spec.rb +92 -0
  81. data/spec/ruby_speech/ssml/say_as_spec.rb +71 -0
  82. data/spec/ruby_speech/ssml/speak_spec.rb +166 -0
  83. data/spec/ruby_speech/ssml/sub_spec.rb +57 -0
  84. data/spec/ruby_speech/ssml/voice_spec.rb +200 -0
  85. data/spec/ruby_speech/ssml_spec.rb +285 -0
  86. data/spec/ruby_speech_spec.rb +124 -0
  87. data/spec/spec_helper.rb +21 -0
  88. data/spec/support/match_examples.rb +43 -0
  89. data/spec/support/matchers.rb +46 -0
  90. metadata +405 -0
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe MaxMatch do
6
+ it_behaves_like "match"
7
+
8
+ it { should be_a Match }
9
+
10
+ describe "equality" do
11
+ it "should never be equal to a MaxMatch" do
12
+ described_class.new.should_not eql(Match.new)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe NoMatch do
6
+ describe "equality" do
7
+ it "should be equal to another NoMatch" do
8
+ NoMatch.new.should == NoMatch.new
9
+ end
10
+
11
+ it "should not equal a match" do
12
+ NoMatch.new.should_not == Match.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe OneOf do
6
+ its(:name) { should == 'one-of' }
7
+
8
+ it 'registers itself' do
9
+ Element.class_from_registration(:'one-of').should == OneOf
10
+ end
11
+
12
+ describe "from a document" do
13
+ let(:document) { '<one-of> <item>test</item> </one-of>' }
14
+
15
+ subject { Element.import document }
16
+
17
+ it { should be_instance_of OneOf }
18
+ end
19
+
20
+ describe "#language" do
21
+ before { subject.language = 'fr-CA' }
22
+
23
+ its(:language) { should == 'fr-CA' }
24
+ end
25
+
26
+ describe "<<" do
27
+ it "should accept Item" do
28
+ lambda { subject << Item.new }.should_not raise_error
29
+ end
30
+
31
+ it "should raise InvalidChildError with non-acceptable objects" do
32
+ lambda { subject << 1 }.should raise_error(InvalidChildError, "A OneOf can only accept Item as children")
33
+ end
34
+ end
35
+
36
+ describe "comparing objects" do
37
+ it "should be equal if the language (when specified) is the same" do
38
+ OneOf.new(:language => "jp").should == OneOf.new(:language => "jp")
39
+ end
40
+
41
+ describe "when the language is different" do
42
+ it "should not be equal" do
43
+ OneOf.new(:language => "jp").should_not == OneOf.new(:content => "fr-CA")
44
+ end
45
+ end
46
+ end
47
+ end # OneOf
48
+ end # GRXML
49
+ end # RubySpeech
@@ -0,0 +1,17 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe PotentialMatch do
6
+ describe "equality" do
7
+ it "should be equal to another PotentialMatch" do
8
+ PotentialMatch.new.should == PotentialMatch.new
9
+ end
10
+
11
+ it "should not equal a match" do
12
+ PotentialMatch.new.should_not == Match.new
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,125 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe Rule do
6
+ subject { Rule.new :id => 'one', :scope => 'public' }
7
+
8
+ its(:name) { should == 'rule' }
9
+
10
+ its(:id) { should == :one }
11
+ its(:scope) { should == :public }
12
+
13
+ it 'registers itself' do
14
+ Element.class_from_registration(:rule).should == Rule
15
+ end
16
+
17
+ describe "from a document" do
18
+ let(:document) { '<rule id="one" scope="public"> <item /> </rule>' }
19
+
20
+ subject { Element.import document }
21
+
22
+ it { should be_instance_of Rule }
23
+
24
+ its(:id) { should == :one }
25
+ its(:scope) { should == :public }
26
+ end
27
+
28
+ describe "#language" do
29
+ before { subject.language = 'jp' }
30
+
31
+ its(:language) { should == 'jp' }
32
+ end
33
+
34
+ describe "#id" do
35
+ before { subject.id = :main }
36
+
37
+ its(:id) { should == :main }
38
+
39
+ context "without an id" do
40
+ before { subject.id = nil }
41
+ pending
42
+ end
43
+
44
+ context "with a non-unique id" do
45
+ pending 'this should probably go into the grammar spec'
46
+ end
47
+ end
48
+
49
+ describe "#scope" do
50
+ before { subject.scope = :public }
51
+
52
+ its(:scope) { should == :public }
53
+
54
+ it "with a valid scope" do
55
+ lambda { subject.scope = :public }.should_not raise_error
56
+ lambda { subject.scope = :private }.should_not raise_error
57
+ end
58
+
59
+ it "with an invalid scope" do
60
+ lambda { subject.scope = :something }.should raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
61
+ end
62
+ end
63
+
64
+ describe "comparing objects" do
65
+ it "should be equal if the content, language, id, and scope are the same" do
66
+ Rule.new(:language => 'jp', :id => :main, :scope => :public, :content => "hello").should == Rule.new(:language => 'jp', :id => :main, :scope => :public, :content => "hello")
67
+ end
68
+
69
+ describe "when the content is different" do
70
+ it "should not be equal" do
71
+ Rule.new(:content => "Hello").should_not == Rule.new(:content => "Hello there")
72
+ end
73
+ end
74
+
75
+ describe "when the language is different" do
76
+ it "should not be equal" do
77
+ Rule.new(:language => "jp").should_not == Rule.new(:language => "esperanto")
78
+ end
79
+ end
80
+
81
+ describe "when the id is different" do
82
+ it "should not be equal" do
83
+ Rule.new(:id => :main).should_not == Rule.new(:id => :dtmf)
84
+ end
85
+ end
86
+
87
+ describe "when the scope is different" do
88
+ it "should not be equal" do
89
+ Rule.new(:scope => :public).should_not == Rule.new(:scope => :private)
90
+ end
91
+ end
92
+ end
93
+
94
+ describe "<<" do
95
+ it "should accept String" do
96
+ lambda { subject << 'anything' }.should_not raise_error
97
+ end
98
+
99
+ it "should accept OneOf" do
100
+ lambda { subject << OneOf.new }.should_not raise_error
101
+ end
102
+
103
+ it "should accept Item" do
104
+ lambda { subject << Item.new }.should_not raise_error
105
+ end
106
+
107
+ it "should accept Ruleref" do
108
+ lambda { subject << Ruleref.new }.should_not raise_error
109
+ end
110
+
111
+ it "should accept Tag" do
112
+ lambda { subject << Tag.new }.should_not raise_error
113
+ end
114
+
115
+ it "should accept Token" do
116
+ lambda { subject << Token.new }.should_not raise_error
117
+ end
118
+ end
119
+
120
+ it "should raise ArgumentError with any other scope" do
121
+ lambda { Rule.new :id => 'one', :scope => 'invalid_scope' }.should raise_error(ArgumentError, "A Rule's scope can only be 'public' or 'private'")
122
+ end
123
+ end # Rule
124
+ end # GRXML
125
+ end # RubySpeech
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe Ruleref do
6
+ subject { Ruleref.new :uri => '#testrule' }
7
+
8
+ its(:name) { should == 'ruleref' }
9
+ its(:uri) { should == '#testrule' }
10
+
11
+ it 'registers itself' do
12
+ Element.class_from_registration(:ruleref).should == Ruleref
13
+ end
14
+
15
+ describe "from a document" do
16
+ let(:document) { '<ruleref uri="#one" />' }
17
+
18
+ subject { Element.import document }
19
+
20
+ it { should be_instance_of Ruleref }
21
+
22
+ its(:uri) { should == '#one' }
23
+ end
24
+
25
+ describe "#special" do
26
+ subject { Ruleref.new }
27
+
28
+ context "with reserved values" do
29
+ it "with a valid value" do
30
+ lambda { subject.special = :NULL }.should_not raise_error
31
+ lambda { subject.special = :VOID }.should_not raise_error
32
+ lambda { subject.special = 'GARBAGE' }.should_not raise_error
33
+ end
34
+ it "with an invalid value" do
35
+ lambda { subject.special = :SOMETHINGELSE }.should raise_error
36
+ end
37
+ end
38
+ end
39
+
40
+ describe "#uri" do
41
+ it "allows implict, explicit and external references" do
42
+ lambda { subject.uri = '#dtmf' }.should_not raise_error
43
+ lambda { subject.uri = '../test.grxml' }.should_not raise_error
44
+ lambda { subject.uri = 'http://grammar.example.com/world-cities.grxml#canada' }.should_not raise_error
45
+ end
46
+ end
47
+
48
+ describe "only uri or special can be specified" do
49
+ it "should raise an error" do
50
+ lambda { subject << Ruleref.new(:uri => '#test', :special => :NULL) }.should raise_error(ArgumentError, "A Ruleref can only take uri or special")
51
+ end
52
+ end
53
+ end # Ruleref
54
+ end # GRXML
55
+ end # RubySpeech
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe Tag do
6
+ its(:name) { should == 'tag' }
7
+
8
+ it 'registers itself' do
9
+ Element.class_from_registration(:tag).should == Tag
10
+ end
11
+
12
+ describe "from a document" do
13
+ let(:document) { '<tag>hello</tag>' }
14
+
15
+ subject { Element.import document }
16
+
17
+ it { should be_instance_of Tag }
18
+
19
+ its(:content) { should == 'hello' }
20
+ end
21
+
22
+ describe "comparing objects" do
23
+ it "should be equal if the content is the same" do
24
+ Tag.new(:content => "hello").should == Tag.new(:content => "hello")
25
+ end
26
+
27
+ describe "when the content is different" do
28
+ it "should not be equal" do
29
+ Tag.new(:content => "Hello").should_not == Tag.new(:content => "Hello there")
30
+ end
31
+ end
32
+ end
33
+
34
+ describe "<<" do
35
+ it "should accept String" do
36
+ lambda { subject << 'anything' }.should_not raise_error
37
+ end
38
+ end
39
+ end # Tag
40
+ end # GRXML
41
+ end # RubySpeech
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ module RubySpeech
4
+ module GRXML
5
+ describe Token do
6
+ its(:name) { should == 'token' }
7
+
8
+ it 'registers itself' do
9
+ Element.class_from_registration(:token).should == Token
10
+ end
11
+
12
+ describe "from a document" do
13
+ let(:document) { '<token>hello</token>' }
14
+
15
+ subject { Element.import document }
16
+
17
+ it { should be_instance_of Token }
18
+
19
+ its(:content) { should == 'hello' }
20
+ end
21
+
22
+ describe "#language" do
23
+ before { subject.language = 'jp' }
24
+
25
+ its(:language) { should == 'jp' }
26
+ end
27
+
28
+ describe "#normalize_whitespace" do
29
+ it "should remove leading & trailing whitespace and collapse multiple spaces down to 1" do
30
+ element = Element.import '<token> Welcome to San Francisco </token>'
31
+
32
+ element.normalize_whitespace
33
+
34
+ element.content.should == 'Welcome to San Francisco'
35
+ end
36
+ end
37
+
38
+ describe "comparing objects" do
39
+ it "should be equal if the content is the same" do
40
+ Token.new(:content => "hello").should == Token.new(:content => "hello")
41
+ end
42
+
43
+ describe "when the content is different" do
44
+ it "should not be equal" do
45
+ Token.new(:content => "Hello").should_not == Token.new(:content => "Hello there")
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "<<" do
51
+ it "should accept String" do
52
+ lambda { subject << 'anything' }.should_not raise_error
53
+ end
54
+
55
+ it "should allow chaining" do
56
+ subject << 'foo' << 'bar'
57
+ subject.content.should == 'foobar'
58
+ end
59
+ end
60
+ end # Token
61
+ end # GRXML
62
+ end # RubySpeech