gemmyrb 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/lib/gemmy/components/word_speaker.rb +37 -25
- data/lib/gemmy/tasks/make_gem.rb +2 -2
- data/lib/gemmy/version.rb +1 -1
- data/lib/gemmy.rb +8 -1
- metadata +39 -59
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88d44792783df72bba22788805d9c9921a076e38
|
4
|
+
data.tar.gz: 37b1cfe226df4006674b30f53c89b0376edde271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feb8fe730f9fcd32dd0ebfb5fc10e6fe3eeb58de5be37654d42d1adefb04bcc6c82a354803c33a841f85cf1af7ccfd13ead3fb902a6ac8ed872b34437d117c27
|
7
|
+
data.tar.gz: 6dc21be406312cdc5a00d0a00c871d6b8bf3a8966d7d31a40df7e2f7724930257d18ed1682ff90d539f10a5df5746f7575dbc792be1d0258c3bf411f6f7298fd
|
data/README.md
CHANGED
@@ -21,6 +21,9 @@ documents:
|
|
21
21
|
- [examples/02_using_globally.rb](./examples/02_using_globally.rb)
|
22
22
|
- _Shell commands and other one-off processes_
|
23
23
|
- [examples/03_shell_commands.rb](./examples/03_shell_commands.rb)
|
24
|
+
- _Natural language utilities_
|
25
|
+
- [examples/04_language_stuff.rb](./examples/04_language_stuff.rb)
|
26
|
+
|
24
27
|
|
25
28
|
**To see a full list of the patched methods, see the [rubydoc](http://www.rubydoc.info/gems/gemmyrb)**
|
26
29
|
|
@@ -1,13 +1,10 @@
|
|
1
1
|
module Gemmy::Components::WordSpeaker
|
2
|
-
include ESpeak
|
3
2
|
|
4
3
|
Gemmy.patches.each { |x| using x }
|
5
4
|
|
6
|
-
def speak_sentence(
|
7
|
-
Gemmy
|
8
|
-
|
9
|
-
container_length,
|
10
|
-
).speak(path: path)
|
5
|
+
def speak_sentence(*args)
|
6
|
+
sentence = Gemmy.component("word_speaker/sentence").new(*args)
|
7
|
+
sentence.save_to_file.speak_file
|
11
8
|
end
|
12
9
|
|
13
10
|
class Sentence
|
@@ -19,32 +16,47 @@ module Gemmy::Components::WordSpeaker
|
|
19
16
|
%i{
|
20
17
|
sentence
|
21
18
|
sentence_syllables
|
22
|
-
|
23
|
-
|
19
|
+
syllables
|
20
|
+
syllable_length
|
21
|
+
path
|
22
|
+
word_paths
|
23
|
+
total_len
|
24
|
+
cached
|
25
|
+
silent
|
26
|
+
idx
|
27
|
+
}.each &m(:attr_accessor)
|
24
28
|
|
25
|
-
def initialize(
|
29
|
+
def initialize(
|
30
|
+
sentence:, syllables: 8, syllable_length: 0.2, path: nil, cached: false,
|
31
|
+
silent: false
|
32
|
+
)
|
26
33
|
@sentence = sentence
|
27
34
|
@sentence_syllables = @sentence.syllable_count.to_f
|
28
|
-
@
|
35
|
+
@syllables = syllables.to_f
|
36
|
+
@path = path
|
37
|
+
@syllable_length = syllable_length.to_f
|
38
|
+
@total_len = syllable_length * @syllables
|
39
|
+
@cached = cached
|
40
|
+
@silent = silent
|
41
|
+
@idx = 0
|
29
42
|
end
|
30
43
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
`
|
44
|
+
def save_to_file
|
45
|
+
return self if @sentence.empty? || cached
|
46
|
+
`espeak -v english-us -w #{path} "#{sentence}"`
|
47
|
+
sentence_len = `soxi -D #{path}`.to_f
|
48
|
+
diff = 1 / (total_len / sentence_len)
|
49
|
+
tmp_path = "wav/tmp.wav"
|
50
|
+
`sox #{path} #{tmp_path} tempo #{diff.round(2)}`
|
51
|
+
`rm #{path}`
|
52
|
+
`mv #{tmp_path} #{path}`
|
53
|
+
self
|
40
54
|
end
|
41
55
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
def diff_multiplier
|
47
|
-
1.0 / diff_factor
|
56
|
+
def speak_file
|
57
|
+
return self if @sentence.empty? || silent
|
58
|
+
`aplay #{path}`
|
59
|
+
self
|
48
60
|
end
|
49
61
|
|
50
62
|
end
|
data/lib/gemmy/tasks/make_gem.rb
CHANGED
@@ -34,7 +34,7 @@ class Gemmy::Tasks::MakeGem
|
|
34
34
|
#
|
35
35
|
def make_gem(name)
|
36
36
|
@name = name
|
37
|
-
@class_name = name.
|
37
|
+
@class_name = name.camelcase
|
38
38
|
|
39
39
|
usage_io
|
40
40
|
create_root_dir
|
@@ -136,7 +136,7 @@ class Gemmy::Tasks::MakeGem
|
|
136
136
|
gemspec_text = <<-TXT.unindent
|
137
137
|
require_relative './lib/version.rb'
|
138
138
|
Gem::Specification.new do |s|
|
139
|
-
s.name = name
|
139
|
+
s.name = "#{name}"
|
140
140
|
s.version = #{class_name}::VERSION
|
141
141
|
s.date = "#{Time.now.strftime("%Y-%m-%d")}"
|
142
142
|
s.summary = "#{summary}"
|
data/lib/gemmy/version.rb
CHANGED
data/lib/gemmy.rb
CHANGED
@@ -8,12 +8,19 @@ require 'corefines'
|
|
8
8
|
require 'sentence_interpreter'
|
9
9
|
require 'engtagger'
|
10
10
|
require 'odyssey'
|
11
|
-
require 'espeak'
|
12
11
|
|
13
12
|
# Container class for all the functionality.
|
14
13
|
#
|
15
14
|
class Gemmy
|
16
15
|
|
16
|
+
# Slightly friendlier way to reference component classes
|
17
|
+
# Gemmy.component("word_speaker/sentence")
|
18
|
+
def self.component(path)
|
19
|
+
Gemmy::Components.const_get(
|
20
|
+
path.split("/").map { |part| part.camelcase }.join("::")
|
21
|
+
)
|
22
|
+
end
|
23
|
+
|
17
24
|
# Used by patches to get a reference to static patch classes
|
18
25
|
# Without this there would be long, unqualified constant names such as
|
19
26
|
# Gemmy::Patches::SymbolPatch::InstanceMethods::Call
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemmyrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- max pleaner
|
@@ -14,92 +14,86 @@ dependencies:
|
|
14
14
|
name: colored
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: activesupport
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '4.2'
|
34
31
|
- - ">="
|
35
32
|
- !ruby/object:Gem::Version
|
36
|
-
version:
|
33
|
+
version: '0'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
|
-
- - "~>"
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: '4.2'
|
44
38
|
- - ">="
|
45
39
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
40
|
+
version: '0'
|
47
41
|
- !ruby/object:Gem::Dependency
|
48
42
|
name: pry
|
49
43
|
requirement: !ruby/object:Gem::Requirement
|
50
44
|
requirements:
|
51
|
-
- - "
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0
|
47
|
+
version: '0'
|
54
48
|
type: :runtime
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
51
|
requirements:
|
58
|
-
- - "
|
52
|
+
- - ">="
|
59
53
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0
|
54
|
+
version: '0'
|
61
55
|
- !ruby/object:Gem::Dependency
|
62
56
|
name: byebug
|
63
57
|
requirement: !ruby/object:Gem::Requirement
|
64
58
|
requirements:
|
65
|
-
- - "
|
59
|
+
- - ">="
|
66
60
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
61
|
+
version: '0'
|
68
62
|
type: :runtime
|
69
63
|
prerelease: false
|
70
64
|
version_requirements: !ruby/object:Gem::Requirement
|
71
65
|
requirements:
|
72
|
-
- - "
|
66
|
+
- - ">="
|
73
67
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
68
|
+
version: '0'
|
75
69
|
- !ruby/object:Gem::Dependency
|
76
70
|
name: thor
|
77
71
|
requirement: !ruby/object:Gem::Requirement
|
78
72
|
requirements:
|
79
|
-
- - "
|
73
|
+
- - ">="
|
80
74
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0
|
75
|
+
version: '0'
|
82
76
|
type: :runtime
|
83
77
|
prerelease: false
|
84
78
|
version_requirements: !ruby/object:Gem::Requirement
|
85
79
|
requirements:
|
86
|
-
- - "
|
80
|
+
- - ">="
|
87
81
|
- !ruby/object:Gem::Version
|
88
|
-
version: 0
|
82
|
+
version: '0'
|
89
83
|
- !ruby/object:Gem::Dependency
|
90
84
|
name: corefines
|
91
85
|
requirement: !ruby/object:Gem::Requirement
|
92
86
|
requirements:
|
93
|
-
- - "
|
87
|
+
- - ">="
|
94
88
|
- !ruby/object:Gem::Version
|
95
|
-
version:
|
89
|
+
version: '0'
|
96
90
|
type: :runtime
|
97
91
|
prerelease: false
|
98
92
|
version_requirements: !ruby/object:Gem::Requirement
|
99
93
|
requirements:
|
100
|
-
- - "
|
94
|
+
- - ">="
|
101
95
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
96
|
+
version: '0'
|
103
97
|
- !ruby/object:Gem::Dependency
|
104
98
|
name: sentence_interpreter
|
105
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,72 +112,58 @@ dependencies:
|
|
118
112
|
name: awesome_print
|
119
113
|
requirement: !ruby/object:Gem::Requirement
|
120
114
|
requirements:
|
121
|
-
- - "
|
115
|
+
- - ">="
|
122
116
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
117
|
+
version: '0'
|
124
118
|
type: :runtime
|
125
119
|
prerelease: false
|
126
120
|
version_requirements: !ruby/object:Gem::Requirement
|
127
121
|
requirements:
|
128
|
-
- - "
|
122
|
+
- - ">="
|
129
123
|
- !ruby/object:Gem::Version
|
130
|
-
version:
|
124
|
+
version: '0'
|
131
125
|
- !ruby/object:Gem::Dependency
|
132
126
|
name: engtagger
|
133
127
|
requirement: !ruby/object:Gem::Requirement
|
134
128
|
requirements:
|
135
|
-
- - "
|
129
|
+
- - ">="
|
136
130
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0
|
131
|
+
version: '0'
|
138
132
|
type: :runtime
|
139
133
|
prerelease: false
|
140
134
|
version_requirements: !ruby/object:Gem::Requirement
|
141
135
|
requirements:
|
142
|
-
- - "
|
136
|
+
- - ">="
|
143
137
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0
|
138
|
+
version: '0'
|
145
139
|
- !ruby/object:Gem::Dependency
|
146
140
|
name: minitest
|
147
141
|
requirement: !ruby/object:Gem::Requirement
|
148
142
|
requirements:
|
149
|
-
- - "
|
143
|
+
- - ">="
|
150
144
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
145
|
+
version: '0'
|
152
146
|
type: :runtime
|
153
147
|
prerelease: false
|
154
148
|
version_requirements: !ruby/object:Gem::Requirement
|
155
149
|
requirements:
|
156
|
-
- - "
|
150
|
+
- - ">="
|
157
151
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
152
|
+
version: '0'
|
159
153
|
- !ruby/object:Gem::Dependency
|
160
154
|
name: odyssey
|
161
155
|
requirement: !ruby/object:Gem::Requirement
|
162
156
|
requirements:
|
163
|
-
- - "
|
164
|
-
- !ruby/object:Gem::Version
|
165
|
-
version: 0.2.0
|
166
|
-
type: :runtime
|
167
|
-
prerelease: false
|
168
|
-
version_requirements: !ruby/object:Gem::Requirement
|
169
|
-
requirements:
|
170
|
-
- - "~>"
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
version: 0.2.0
|
173
|
-
- !ruby/object:Gem::Dependency
|
174
|
-
name: espeak-ruby
|
175
|
-
requirement: !ruby/object:Gem::Requirement
|
176
|
-
requirements:
|
177
|
-
- - "~>"
|
157
|
+
- - ">="
|
178
158
|
- !ruby/object:Gem::Version
|
179
|
-
version:
|
159
|
+
version: '0'
|
180
160
|
type: :runtime
|
181
161
|
prerelease: false
|
182
162
|
version_requirements: !ruby/object:Gem::Requirement
|
183
163
|
requirements:
|
184
|
-
- - "
|
164
|
+
- - ">="
|
185
165
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
166
|
+
version: '0'
|
187
167
|
description: ''
|
188
168
|
email: maxpleaner@gmail.com
|
189
169
|
executables:
|