ruby_speech 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +43 -11
- data/README.md +1 -1
- data/lib/ruby_speech/ssml/element.rb +15 -0
- data/lib/ruby_speech/version.rb +1 -1
- data/spec/ruby_speech/ssml_spec.rb +66 -0
- metadata +20 -20
data/CHANGELOG.md
CHANGED
@@ -1,25 +1,57 @@
|
|
1
|
+
# 0.2.2
|
2
|
+
* Feature: The SSML DSL now supports embedding SSML documents, elements or strings via the `embed` method. This behaves as you might expect:
|
3
|
+
|
4
|
+
```ruby
|
5
|
+
doc1 = RubySpeech::SSML.draw do
|
6
|
+
string "Hi, I'm Fred. The time is currently "
|
7
|
+
say_as :interpret_as => 'date', :format => 'dmy' do
|
8
|
+
"01/02/1960"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
doc2 = RubySpeech::SSML.draw do
|
13
|
+
voice :gender => :male, :name => 'fred' do
|
14
|
+
embed doc1
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
doc2.to_s
|
19
|
+
```
|
20
|
+
|
21
|
+
```xml
|
22
|
+
<speak xmlns="http://www.w3.org/2001/10/synthesis" version="1.0" xml:lang="en-US">
|
23
|
+
<voice gender="male" name="fred">
|
24
|
+
Hi, I'm Fred. The time is currently
|
25
|
+
<say-as interpret-as="date" format="dmy">
|
26
|
+
01/02/1960
|
27
|
+
</say-as>
|
28
|
+
</voice>
|
29
|
+
</speak>
|
30
|
+
```
|
31
|
+
|
1
32
|
# 0.2.1
|
2
|
-
Bugfix: SSML element's children now include any text content, and text content is copied when importing/concatenating documents
|
33
|
+
* Bugfix: SSML element's children now include any text content, and text content is copied when importing/concatenating documents
|
3
34
|
|
4
35
|
# 0.2.0
|
5
|
-
|
6
|
-
Feature: SSML elements now
|
7
|
-
|
36
|
+
* API Change: SSML::SayAs.new (and the DSL method `say_as`) now take `:interpret_as` in the options hash, rather than a separate first argument. This is for consistency with the other element types.
|
37
|
+
* Feature: SSML elements can now be imported from a Nokogiri Node or a string
|
38
|
+
* Feature: SSML elements now respond to #children with an array of SSML elements, rather than a Nokogiri NodeSet
|
39
|
+
* Bugfix/Feature: Comparing SSML elements now compares children
|
8
40
|
|
9
41
|
# 0.1.5
|
10
|
-
Feature: Now added support for SSML
|
42
|
+
* Feature: Now added support for SSML `<audio/>`
|
11
43
|
|
12
44
|
# 0.1.4
|
13
|
-
Bugfix: Speak#+ now returns a brand new Speak rather than modifying the original object
|
14
|
-
Bugfix: Speak#+ now re-sets the namespace on child elements to ensure no default namespace prefix is added
|
45
|
+
* Bugfix: Speak#+ now returns a brand new Speak rather than modifying the original object
|
46
|
+
* Bugfix: Speak#+ now re-sets the namespace on child elements to ensure no default namespace prefix is added
|
15
47
|
|
16
48
|
# 0.1.3
|
17
|
-
Bugfix: Strings included via the DSL (both as a block return value and by calling #string) are now properly escaped
|
49
|
+
* Bugfix: Strings included via the DSL (both as a block return value and by calling #string) are now properly escaped
|
18
50
|
|
19
51
|
# 0.1.2
|
20
|
-
API Change: SSML.draw now returns a Speak
|
21
|
-
Feature: Speak objects can be turned into an XML document using #to_doc
|
22
|
-
Feature: Speak objects can now be concatenated such that children are merged together
|
52
|
+
* API Change: SSML.draw now returns a Speak
|
53
|
+
* Feature: Speak objects can be turned into an XML document using #to_doc
|
54
|
+
* Feature: Speak objects can now be concatenated such that children are merged together
|
23
55
|
|
24
56
|
# 0.1.1
|
25
57
|
* Bugfix: DSL now allows for nesting all allowed elements within each other
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ require 'ruby_speech'
|
|
13
13
|
speak = RubySpeech::SSML.draw do
|
14
14
|
voice gender: :male, name: 'fred' do
|
15
15
|
string "Hi, I'm Fred. The time is currently "
|
16
|
-
say_as 'date', format: 'dmy' do
|
16
|
+
say_as interpret_as: 'date', format: 'dmy' do
|
17
17
|
"01/02/1960"
|
18
18
|
end
|
19
19
|
end
|
@@ -70,6 +70,21 @@ module RubySpeech
|
|
70
70
|
super.map { |c| Element.import c }
|
71
71
|
end
|
72
72
|
|
73
|
+
def embed(other)
|
74
|
+
case other
|
75
|
+
when String
|
76
|
+
self << encode_special_chars(other)
|
77
|
+
when Speak
|
78
|
+
other.children.each do |child|
|
79
|
+
self << child
|
80
|
+
end
|
81
|
+
when Element
|
82
|
+
self << other
|
83
|
+
else
|
84
|
+
raise ArgumentError, "Can only embed a String or an SSML element"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
73
88
|
def method_missing(method_name, *args, &block)
|
74
89
|
const_name = method_name.to_s.sub('ssml', '').titleize.gsub(' ', '')
|
75
90
|
const = SSML.const_get const_name
|
data/lib/ruby_speech/version.rb
CHANGED
@@ -56,6 +56,72 @@ module RubySpeech
|
|
56
56
|
doc.should == expected_doc
|
57
57
|
end
|
58
58
|
|
59
|
+
describe "embedding" do
|
60
|
+
it "SSML documents" do
|
61
|
+
doc1 = RubySpeech::SSML.draw do
|
62
|
+
string "Hi, I'm Fred. The time is currently "
|
63
|
+
say_as :interpret_as => 'date', :format => 'dmy' do
|
64
|
+
"01/02/1960"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
doc2 = RubySpeech::SSML.draw do
|
69
|
+
voice :gender => :male, :name => 'fred' do
|
70
|
+
embed doc1
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
expected_doc = RubySpeech::SSML.draw do
|
75
|
+
voice :gender => :male, :name => 'fred' do
|
76
|
+
string "Hi, I'm Fred. The time is currently "
|
77
|
+
say_as :interpret_as => 'date', :format => 'dmy' do
|
78
|
+
"01/02/1960"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
doc2.should == expected_doc
|
84
|
+
end
|
85
|
+
|
86
|
+
it "SSML elements" do
|
87
|
+
element = SSML::Emphasis.new(:content => "HELLO?")
|
88
|
+
|
89
|
+
doc = RubySpeech::SSML.draw do
|
90
|
+
voice :gender => :male, :name => 'fred' do
|
91
|
+
embed element
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
expected_doc = RubySpeech::SSML.draw do
|
96
|
+
voice :gender => :male, :name => 'fred' do
|
97
|
+
emphasis do
|
98
|
+
"HELLO?"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
doc.should == expected_doc
|
104
|
+
end
|
105
|
+
|
106
|
+
it "strings" do
|
107
|
+
string = "How now, brown cow?"
|
108
|
+
|
109
|
+
doc = RubySpeech::SSML.draw do
|
110
|
+
voice :gender => :male, :name => 'fred' do
|
111
|
+
embed string
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
expected_doc = RubySpeech::SSML.draw do
|
116
|
+
voice :gender => :male, :name => 'fred' do
|
117
|
+
string "How now, brown cow?"
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
doc.should == expected_doc
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
59
125
|
it "should properly escape string input" do
|
60
126
|
doc = RubySpeech::SSML.draw do
|
61
127
|
voice { string "I <3 nachos." }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_speech
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-09-12 00:00:00.000000000 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: niceogiri
|
17
|
-
requirement: &
|
17
|
+
requirement: &2153165820 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: 0.0.4
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153165820
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activesupport
|
28
|
-
requirement: &
|
28
|
+
requirement: &2153165300 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: 3.0.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153165300
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &2153164820 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ~>
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: 1.0.0
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153164820
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rspec
|
50
|
-
requirement: &
|
50
|
+
requirement: &2153164340 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ~>
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: 2.3.0
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153164340
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: ci_reporter
|
61
|
-
requirement: &
|
61
|
+
requirement: &2153163860 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: 1.6.3
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2153163860
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: yard
|
72
|
-
requirement: &
|
72
|
+
requirement: &2153163380 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ~>
|
@@ -77,10 +77,10 @@ dependencies:
|
|
77
77
|
version: 0.7.0
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2153163380
|
81
81
|
- !ruby/object:Gem::Dependency
|
82
82
|
name: rake
|
83
|
-
requirement: &
|
83
|
+
requirement: &2153162900 !ruby/object:Gem::Requirement
|
84
84
|
none: false
|
85
85
|
requirements:
|
86
86
|
- - ! '>='
|
@@ -88,10 +88,10 @@ dependencies:
|
|
88
88
|
version: '0'
|
89
89
|
type: :development
|
90
90
|
prerelease: false
|
91
|
-
version_requirements: *
|
91
|
+
version_requirements: *2153162900
|
92
92
|
- !ruby/object:Gem::Dependency
|
93
93
|
name: mocha
|
94
|
-
requirement: &
|
94
|
+
requirement: &2153162420 !ruby/object:Gem::Requirement
|
95
95
|
none: false
|
96
96
|
requirements:
|
97
97
|
- - ! '>='
|
@@ -99,10 +99,10 @@ dependencies:
|
|
99
99
|
version: '0'
|
100
100
|
type: :development
|
101
101
|
prerelease: false
|
102
|
-
version_requirements: *
|
102
|
+
version_requirements: *2153162420
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: i18n
|
105
|
-
requirement: &
|
105
|
+
requirement: &2153161940 !ruby/object:Gem::Requirement
|
106
106
|
none: false
|
107
107
|
requirements:
|
108
108
|
- - ! '>='
|
@@ -110,7 +110,7 @@ dependencies:
|
|
110
110
|
version: '0'
|
111
111
|
type: :development
|
112
112
|
prerelease: false
|
113
|
-
version_requirements: *
|
113
|
+
version_requirements: *2153161940
|
114
114
|
description: Prepare SSML and GRXML documents with ease
|
115
115
|
email:
|
116
116
|
- ben@langfeld.me
|