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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0c41708d5556ece1a2ff900a24615f6db8519ec
4
- data.tar.gz: 7ea69b6d4db98463a13cf1b92be74137fd1f94e3
3
+ metadata.gz: 88d44792783df72bba22788805d9c9921a076e38
4
+ data.tar.gz: 37b1cfe226df4006674b30f53c89b0376edde271
5
5
  SHA512:
6
- metadata.gz: 4215dd2dd05967451796a4c0f33f4159b99c723b6e3e8d2e047fe43cc75a8a289267c599c15eaa13401302555240d91b07929dcf6011eed1b5ff56f117ec06cc
7
- data.tar.gz: 6d00ca0e4d47f27a82f6d8a3ba6b2de76bbd3d4308f91484d734b827f900cef460462c93e2fe214210e99aa82ad5082d8a11fcc5d26a179dabd8790c53be11b4
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(sentence, container_length=8, path: nil)
7
- Gemmy::Components::WordSpeaker::Sentence.new(
8
- sentence,
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
- container_length
23
- }.each &m(:attr_reader)
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(sentence, container_length)
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
- @container_length = container_length.to_f
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 speak(path: nil)
32
- pitch = DefaultPitch * diff_multiplier
33
- speed = DefaultSpeed * diff_factor
34
- gap = DefaultGap * diff_multiplier
35
- espeak_opts = "-v english-us -p #{pitch} -s #{speed}"
36
- if path
37
- espeak_opts += " -w #{path}"
38
- end
39
- `espeak #{espeak_opts} "#{sentence}"`
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 diff_factor
43
- sentence_syllables / container_length
44
- end
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
@@ -34,7 +34,7 @@ class Gemmy::Tasks::MakeGem
34
34
  #
35
35
  def make_gem(name)
36
36
  @name = name
37
- @class_name = name.capitalize
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
@@ -1,3 +1,3 @@
1
1
  class Gemmy
2
- VERSION = '0.0.8'
2
+ VERSION = '0.0.9'
3
3
  end
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.8
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: '1.2'
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: '1.2'
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: 4.2.7
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: 4.2.7
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.10.4
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.10.4
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: 9.0.6
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: 9.0.6
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.19.4
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.19.4
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: 1.9.0
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: 1.9.0
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: 1.7.0
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: 1.7.0
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.2.1
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.2.1
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: 5.10.1
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: 5.10.1
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: 1.0.3
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: 1.0.3
166
+ version: '0'
187
167
  description: ''
188
168
  email: maxpleaner@gmail.com
189
169
  executables: