voxbi 1.0 → 1.0.1

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: 05056623951099fe54a19cc240148481ee89a86e
4
- data.tar.gz: b60a9b28c61553f53b104ceb6bb8576900d49942
3
+ metadata.gz: 66709d394039ca32bf2e281070564b930df34563
4
+ data.tar.gz: 92ee45c2410eb395252fed922f5a101776c4d820
5
5
  SHA512:
6
- metadata.gz: 5a3f3878b356561b8ff19ea66e61706bd7256370220414ea26806d61bbd0aa5c4e55882c4a4fd64f0775697d1f3152454c72a2e43eb73696db2212edf560e79d
7
- data.tar.gz: a51f578adb007d28c8927a609b7bded9bf4ed58032d302d2b8e58ad49b653b04cc280a03ad8006b7414da9c90290f0cd9f17d0c15be9b4959005e128875fcef9
6
+ metadata.gz: c6f273ead2258f7ecb5c8a468b73f5691052025c2d7224f657eb2243fe62843c440b70175f48ea6ff53da47b679cec6c3c11ed395ff7eb32518ec282c552befa
7
+ data.tar.gz: 39b04b8eb7ce1d87e35c3dde0a847925fbd0efa99ec095a69d33fca4183202c8ea8583385f5a8d77c7f50f1508419afde29739cbd3485985a225dfd5a5218120
data/data/pairs.wav CHANGED
Binary file
@@ -3,23 +3,13 @@ require "csv"
3
3
 
4
4
  module Rulable
5
5
  DATA_PATH = File.expand_path('../../data', __dir__)
6
- CSV_FILENAMES = %w(conversion linkage exceptions available_pairs).freeze
7
- JSON_FILENAMES = %w(dictionary).freeze
6
+ CSV_FILENAMES = %i(conversion linkage exceptions available_pairs).freeze
7
+ JSON_FILENAMES = %i(dictionary).freeze
8
8
 
9
- CSV_FILENAMES.each do |filename|
10
- define_method(filename) do
11
- memoize_file_content(filename, :csv)
12
- end
13
- end
14
-
15
- JSON_FILENAMES.each do |filename|
16
- define_method(filename) do
17
- memoize_file_content(filename, :json)
18
- end
9
+ def self.included(klass)
10
+ klass.extend(Macros)
19
11
  end
20
12
 
21
- private
22
-
23
13
  def memoize_file_content(filename, file_format)
24
14
  instance_variable_get("@#{filename}") ||
25
15
  instance_variable_set("@#{filename}", parse_rule_file(filename, file_format))
@@ -44,4 +34,23 @@ module Rulable
44
34
  "#{DATA_PATH}/#{filename}" + ".#{file_format}"
45
35
  end
46
36
 
37
+ module Macros
38
+ def memoize_csv(*filenames)
39
+ permitted_filenames = filenames.select{ |filename| CSV_FILENAMES.include?(filename) }
40
+ memoize_file(permitted_filenames, file_format: :csv)
41
+ end
42
+
43
+ def memoize_json(*filenames)
44
+ permitted_filenames = filenames.select{ |filename| JSON_FILENAMES.include?(filename) }
45
+ memoize_file(permitted_filenames, file_format: :json)
46
+ end
47
+
48
+ def memoize_file(filenames, file_format:)
49
+ filenames.each do |filename|
50
+ define_method(filename) do
51
+ memoize_file_content(filename, file_format)
52
+ end
53
+ end
54
+ end
55
+ end
47
56
  end
@@ -1,6 +1,8 @@
1
1
  class GetPairsService
2
2
  include Rulable
3
3
 
4
+ memoize_csv :available_pairs
5
+
4
6
  attr_reader :phonetic_text
5
7
 
6
8
  def initialize(phonetic_text)
@@ -1,6 +1,8 @@
1
1
  class LinkageService
2
2
  include Rulable
3
3
 
4
+ memoize_csv :linkage
5
+
4
6
  attr_accessor :prepared_text, :phonetic_text
5
7
 
6
8
  def initialize(prepared_text, phonetic_text)
@@ -9,10 +11,7 @@ class LinkageService
9
11
  end
10
12
 
11
13
  def call
12
- dup_phonetic_text
13
14
  apply_linkage
14
-
15
- @dup_phonetic_text
16
15
  end
17
16
 
18
17
  private
@@ -23,15 +22,17 @@ class LinkageService
23
22
 
24
23
  def apply_linkage
25
24
  prepared_text.each_with_index do |word, index|
26
- if @dup_phonetic_text[index+1]
27
- link_string = word[-1] + @dup_phonetic_text[index+1][0]
25
+ if dup_phonetic_text[index+1]
26
+ link_string = word[-1] + dup_phonetic_text[index+1][0]
28
27
  linkage_rule = linkage_rule_for(link_string)
29
28
 
30
29
  if linkage_rule
31
- @dup_phonetic_text[index+1] = linkage_rule[1].to_s + @dup_phonetic_text[index+1]
30
+ dup_phonetic_text[index+1] = linkage_rule[1].to_s + dup_phonetic_text[index+1]
32
31
  end
33
32
  end
34
33
  end
34
+
35
+ dup_phonetic_text
35
36
  end
36
37
 
37
38
  def linkage_rule_for(link_string)
@@ -3,6 +3,8 @@ require "timeout"
3
3
  class PhoneticsConverterService
4
4
  include Rulable
5
5
 
6
+ memoize_csv :conversion
7
+
6
8
  DEFAULT_TIMEOUT = 5.freeze
7
9
 
8
10
  attr_accessor :word, :phonetized_word
data/lib/voxbi.rb CHANGED
@@ -11,6 +11,8 @@ DEFAULT_OUTPUT_PATH = "#{DATA_PATH}/#{DEFAULT_OUTPUT_FILENAME}.wav".freeze
11
11
  class Voxbi
12
12
  include Rulable
13
13
 
14
+ memoize_json :dictionary
15
+
14
16
  attr_accessor :text
15
17
 
16
18
  def initialize(text)
data/voxbi-1.0.gem ADDED
Binary file
data/voxbi.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'voxbi'
3
- s.version = '1.0'
3
+ s.version = '1.0.1'
4
4
  s.date = '2018-04-03'
5
5
  s.summary = "VoxBi"
6
6
  s.description = "Easy-to-use french voice synthesizer"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxbi
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galaad Gauthier
@@ -325,6 +325,7 @@ files:
325
325
  - lib/services/phonetics_converter_service.rb
326
326
  - lib/services/prepare_text_service.rb
327
327
  - lib/voxbi.rb
328
+ - voxbi-1.0.gem
328
329
  - voxbi.gemspec
329
330
  homepage: https://github.com/Galaad-Gauthier/VoxBi
330
331
  licenses: