voxbi 0.2.0 → 0.2.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c02312f9eaa459fcc53162cbcfe6dc5d3dfc662f
4
- data.tar.gz: 195cad166fa6f1583db9756d77943481009ab79e
3
+ metadata.gz: c2c867eb29f361e869e15825cc3e6749de2ffc3e
4
+ data.tar.gz: b3757442ed64298f197c842163534371378e88fd
5
5
  SHA512:
6
- metadata.gz: 621c3052d8f666450a76e9a8142bd8cb80f81335e35e34a44b5f034bc7fb5fa662deb923d168a55aa50163c59c4e1ce39857aaf63c1e405685c565876b1c1a93
7
- data.tar.gz: b2476a29cbd4f7ed419cf9a6d1905d5610cea6047be23a5d2fc752c3533e8486728a9d1ccb66e06e3f0efff504bf8b278b870004aeb627cdcac42a81b9fe9903
6
+ metadata.gz: fa062d4b43a2da029c439e991de8b14e1feab5c2d7799d8d7f1fa7e72f89b5671553197c54fc8fd09672ebe49c6cbea1a02dffafac482cae8286042180961667
7
+ data.tar.gz: 35b2d04044bab18ff19e3a3b3f03c1ce9cdfef62dd9e2794ea108d46e92ec0cf13004684803fbe5679d24dec87344747582462273d81d7d6e439f0ee7f73e1e5
data/README.md CHANGED
@@ -21,6 +21,8 @@ Playing WAVE '/home/<USER>/.gem/ruby/gems/voxbi-0.1.4/data/paires.wav'
21
21
  *Use voxbi as a library*
22
22
 
23
23
  ~~~
24
- > voxbi("Voulez vous coucher avec moi ce soir ?")
24
+ > require "voxbi"
25
+
26
+ > Voxbi.voxbi("Voulez vous coucher avec moi ce soir ?")
25
27
  => Playing WAVE '/home/<USER>/.gem/ruby/gems/voxbi-0.1.4/data/paires.wav'
26
28
  ~~~
data/bin/voxbi CHANGED
@@ -4,4 +4,4 @@ require "json"
4
4
  root = File.expand_path("../..", __FILE__)
5
5
  require "#{root}/lib/voxbi.rb"
6
6
 
7
- voxbi(ARGV[0])
7
+ Voxbi.voxbi(ARGV[0])
@@ -0,0 +1,4 @@
1
+ est#ɛ
2
+ ta#ta
3
+ sa#sa
4
+ belles#bɛl
data/data/liaisons.csv CHANGED
@@ -2,5 +2,4 @@
2
2
  ^x(?=['ɛ','ø','α','ϵ','i','a','o','ɔ','σ','y','u','œ','π','e','µ'])#z
3
3
  ^p(?=['ɛ','ø','α','ϵ','i','a','o','ɔ','σ','y','u','œ','π','e','µ'])#p
4
4
  ^n(?=['ɛ','ø','α','ϵ','i','a','o','ɔ','σ','y','u','œ','π','e','µ'])#n
5
- ^t(?=['ɛ','ø','α','ϵ','i','a','o','ɔ','σ','y','u','œ','π','e','µ'])#t
6
5
  ^r(?=['ɛ','ø','α','ϵ','i','a','o','ɔ','σ','y','u','œ','π','e','µ'])#r
data/data/paires.wav CHANGED
Binary file
@@ -0,0 +1 @@
1
+ SPE = /([(0-9)|•|—|–|\-|\’|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
data/lib/voxbi.rb CHANGED
@@ -2,70 +2,85 @@
2
2
 
3
3
  require "json"
4
4
 
5
- ROOT = File.expand_path("../..", __FILE__)
6
- SPE = /([(0-9)|•|—|–|\-|\’|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
5
+ module Voxbi
7
6
 
8
- def parseCSV(path)
9
- Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
10
- end
7
+ ROOT = File.expand_path("../..", __FILE__)
8
+ FILE_PATH = "#{ROOT}/data/paires.wav"
9
+ eval(File.read("#{ROOT}/lib/special_chars.rb"))
11
10
 
12
- def exceptions
13
- @exceptions ||= JSON.parse(File.read("#{ROOT}/data/phono.json"))
14
- end
11
+ def Voxbi.parseCSV(path)
12
+ Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
13
+ end
15
14
 
16
- def conversion
17
- @conversion ||= parseCSV "conversion"
18
- end
15
+ def Voxbi.dict
16
+ @dict ||= JSON.parse(File.read("#{ROOT}/data/phono.json"))
17
+ end
19
18
 
20
- def liaisons
21
- @liaisons ||= parseCSV "liaisons"
22
- end
19
+ def Voxbi.exceptions
20
+ @exceptions ||= parseCSV "exceptions"
21
+ end
23
22
 
24
- def clean(texte)
25
- return texte.downcase.gsub(SPE, "").split
26
- end
23
+ def Voxbi.conversion
24
+ @conversion ||= parseCSV "conversion"
25
+ end
26
+
27
+ def Voxbi.liaisons
28
+ @liaisons ||= parseCSV "liaisons"
29
+ end
27
30
 
28
- def apimatch(texte)
29
- graphie = clean(texte)
30
- clean_text = clean(texte)
31
- phono = clean_text.map do |mot|
32
- exceptions[mot] || "".tap do |result|
33
- conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
34
- mot.sub! /#{regle}/, ""
35
- result << api.to_s
36
- end until mot.empty?
31
+ def Voxbi.apply_exceptions
32
+ exceptions.each {|k,v| dict[k] = v}
33
+ end
34
+
35
+ def Voxbi.clean(texte)
36
+ return texte.downcase.gsub(SPE, "").split
37
+ end
38
+
39
+ def Voxbi.apimatch(texte)
40
+ apply_exceptions
41
+ graphie = clean(texte)
42
+ clean_text = clean(texte)
43
+ phono = clean_text.map do |mot|
44
+ dict[mot] || "".tap do |result|
45
+ conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
46
+ mot.sub! /#{regle}/, ""
47
+ result << api.to_s
48
+ end until mot.empty?
49
+ end
37
50
  end
51
+ return liaison(graphie,phono)
38
52
  end
39
- return liaison(graphie,phono)
40
- end
41
53
 
42
- def liaison(texte,phono)
43
- texte.each_with_index do |mot,id|
44
- if phono[id+1]
45
- lien = mot[-1] + phono[id+1][0]
46
- match = liaisons.select {|k,v| lien =~ /#{k}/ }.first
47
- match ? phono[id+1] = match[1].to_s + phono[id+1] : next
54
+ def Voxbi.liaison(texte,phono)
55
+ texte.each_with_index do |mot,id|
56
+ if phono[id+1]
57
+ lien = mot[-1] + phono[id+1][0]
58
+ match = liaisons.select {|k,v| lien =~ /#{k}/ }.first
59
+ match ? phono[id+1] = match[1].to_s + phono[id+1] : next
60
+ end
48
61
  end
62
+ return phono
49
63
  end
50
- return phono
51
- end
52
64
 
53
65
 
54
66
 
55
- def voxbi(texte)
56
- paires_dispo = File.open("#{ROOT}/data/paires_disponibles.csv").read.split("\n")
57
- api = apimatch(texte).join "_"
58
- puts api.inspect
59
- fichiers = []
60
- while api.length !=0
61
- paires_dispo.each do |paires|
62
- if api.match(/^#{paires}/)
63
- fichiers << "#{ROOT}/data/paires/#{paires}.ogg"
64
- api = api.sub(/^#{paires}/,"")
65
- break
67
+ def Voxbi.voxbi(texte)
68
+ paires_dispo = File.open("#{ROOT}/data/paires_disponibles.csv").read.split("\n")
69
+ api = apimatch(texte).join "_"
70
+ puts api.inspect
71
+ fichiers = []
72
+ while api.length !=0
73
+ paires_dispo.each do |paires|
74
+ if api.match(/^#{paires}/)
75
+ fichiers << "#{ROOT}/data/paires/#{paires}.ogg"
76
+ api = api.sub(/^#{paires}/,"")
77
+ break
78
+ end
66
79
  end
67
80
  end
81
+ `sox #{fichiers.join(" ")} #{FILE_PATH}`
82
+ `aplay #{FILE_PATH}`
68
83
  end
69
- `sox #{fichiers.join(" ")} #{ROOT}/data/paires.wav`
70
- `aplay #{ROOT}/data/paires.wav`
84
+
85
+
71
86
  end
data/voxbi.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'voxbi'
3
- s.version = '0.2.0'
4
- s.date = '2013-08-30'
3
+ s.version = '0.2.3'
4
+ s.date = '2013-09-04'
5
5
  s.summary = "VoxBi"
6
6
  s.description = "Easy-to-use french voice synthesizer"
7
7
  s.authors = ["Galaad Gauthier"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voxbi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galaad Gauthier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-30 00:00:00.000000000 Z
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -33,6 +33,7 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - voxbi.gemspec
35
35
  - lib/voxbi.rb
36
+ - lib/special_chars.rb
36
37
  - data/paires.wav
37
38
  - data/paires/jɛ.ogg
38
39
  - data/paires/wα.ogg
@@ -285,6 +286,7 @@ files:
285
286
  - data/paires_disponibles.csv
286
287
  - data/conversion.csv
287
288
  - data/phono.json
289
+ - data/exceptions.csv
288
290
  - data/liaisons.csv
289
291
  - phono.json
290
292
  - bin/voxbi