voxbi 0.2.0 → 0.2.3
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 -1
- data/bin/voxbi +1 -1
- data/data/exceptions.csv +4 -0
- data/data/liaisons.csv +0 -1
- data/data/paires.wav +0 -0
- data/lib/special_chars.rb +1 -0
- data/lib/voxbi.rb +64 -49
- data/voxbi.gemspec +2 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2c867eb29f361e869e15825cc3e6749de2ffc3e
|
4
|
+
data.tar.gz: b3757442ed64298f197c842163534371378e88fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
data/data/exceptions.csv
ADDED
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
|
-
|
6
|
-
SPE = /([(0-9)|•|—|–|\-|\’|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
|
5
|
+
module Voxbi
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
13
|
-
|
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
|
17
|
-
|
18
|
-
end
|
15
|
+
def Voxbi.dict
|
16
|
+
@dict ||= JSON.parse(File.read("#{ROOT}/data/phono.json"))
|
17
|
+
end
|
19
18
|
|
20
|
-
def
|
21
|
-
|
22
|
-
end
|
19
|
+
def Voxbi.exceptions
|
20
|
+
@exceptions ||= parseCSV "exceptions"
|
21
|
+
end
|
23
22
|
|
24
|
-
def
|
25
|
-
|
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
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
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
|
-
|
70
|
-
|
84
|
+
|
85
|
+
|
71
86
|
end
|
data/voxbi.gemspec
CHANGED
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.
|
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-
|
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
|