voxbi 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -2
- data/bin/voxbi +2 -45
- data/data/paires.wav +0 -0
- data/lib/voxbi.rb +1 -1
- data/voxbi.gemspec +1 -1
- metadata +1 -2
- data/lib/voxbi.rb~ +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b87bc7c3f0788335b456103556ed58f675e784a7
|
4
|
+
data.tar.gz: 991f5febdc75d7794af20ebcdd4bc162dfcbcf8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2cf9c08ec6f342d5b99fbd1bd90514464cab722d4a17c8afb16dc8ab16ff2dece2f89104d912c0de3efc46ef268d4a23ca236b063d32cbe8ad6c4e485fc51163
|
7
|
+
data.tar.gz: fec2687fc73a8036d9fd89cd139b04f64851239e47defca2345f9dec03807333f353a5254ae86652c013f13a08077fe904a243e25d0391dfc092e32803289f35
|
data/README.md
CHANGED
@@ -9,12 +9,21 @@
|
|
9
9
|
gem install voxbi
|
10
10
|
~~~
|
11
11
|
|
12
|
-
*Use voxbi* :
|
12
|
+
*Use voxbi as an executable* :
|
13
13
|
|
14
14
|
~~~
|
15
15
|
$ voxbi Bonjour
|
16
16
|
|
17
17
|
"bσʒur"
|
18
|
-
Playing WAVE '/home/<USER>/.gem/ruby/gems/voxbi-0.1.
|
18
|
+
Playing WAVE '/home/<USER>/.gem/ruby/gems/voxbi-0.1.4/data/paires.wav'
|
19
19
|
~~~
|
20
20
|
|
21
|
+
*Use voxbi as a library*
|
22
|
+
|
23
|
+
~~~
|
24
|
+
> apimatch("la tour eiffel")
|
25
|
+
=> ["la", "tur", "ɛfɛl"]
|
26
|
+
|
27
|
+
> voxbi("Voulez vous coucher avec moi ce soir ?")
|
28
|
+
=> Playing WAVE '/home/<USER>/.gem/ruby/gems/voxbi-0.1.4/data/paires.wav'
|
29
|
+
~~~
|
data/bin/voxbi
CHANGED
@@ -1,50 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
require "json"
|
4
|
-
|
5
|
-
|
6
|
-
SPE = /([(0-9)|•|—|–|\-|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
|
7
|
-
|
8
|
-
def parseCSV(path)
|
9
|
-
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
10
|
-
end
|
11
|
-
|
12
|
-
def exceptions
|
13
|
-
@exceptions ||= JSON.parse(File.read("#{ROOT}/data/phono.json"))
|
14
|
-
end
|
15
|
-
|
16
|
-
def conversion
|
17
|
-
@conversion ||= parseCSV "conversion"
|
18
|
-
end
|
19
|
-
|
20
|
-
def apimatch(texte)
|
21
|
-
texte = texte.downcase
|
22
|
-
texte.gsub(SPE, "").split.map do |mot|
|
23
|
-
exceptions[mot] || "".tap do |result|
|
24
|
-
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
25
|
-
mot.sub! /#{regle}/, ""
|
26
|
-
result << api.to_s
|
27
|
-
end until mot.empty?
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def voxbi(texte)
|
33
|
-
paires_dispo = File.open("#{ROOT}/data/paires_disponibles.csv").read.split("\n")
|
34
|
-
api = apimatch(texte).join "_"
|
35
|
-
puts api.inspect
|
36
|
-
fichiers = []
|
37
|
-
while api.length !=0
|
38
|
-
paires_dispo.each do |paires|
|
39
|
-
if api.match(/^#{paires}/)
|
40
|
-
fichiers << "#{ROOT}/data/paires/#{paires}.ogg"
|
41
|
-
api = api.sub(/^#{paires}/,"")
|
42
|
-
break
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
`sox #{fichiers.join(" ")} #{ROOT}/data/paires.wav`
|
47
|
-
`aplay #{ROOT}/data/paires.wav`
|
48
|
-
end
|
4
|
+
root = File.expand_path("../..", __FILE__)
|
5
|
+
require "#{root}/lib/voxbi.rb"
|
49
6
|
|
50
7
|
voxbi(ARGV[0])
|
data/data/paires.wav
CHANGED
Binary file
|
data/lib/voxbi.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
ROOT = File.expand_path("../..", __FILE__)
|
6
|
-
SPE = /([(0-9)
|
6
|
+
SPE = /([(0-9)|•|—|–|\-|\’|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
|
7
7
|
|
8
8
|
def parseCSV(path)
|
9
9
|
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
data/voxbi.gemspec
CHANGED
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: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Galaad Gauthier
|
@@ -33,7 +33,6 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- voxbi.gemspec
|
35
35
|
- lib/voxbi.rb
|
36
|
-
- lib/voxbi.rb~
|
37
36
|
- data/paires.wav
|
38
37
|
- data/paires/jɛ.ogg
|
39
38
|
- data/paires/wα.ogg
|
data/lib/voxbi.rb~
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
|
5
|
-
ROOT = File.expand_path("../..", __FILE__)
|
6
|
-
SPE = /([(0-9)|•|—|–|\-|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
|
7
|
-
|
8
|
-
def parseCSV(path)
|
9
|
-
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
10
|
-
end
|
11
|
-
|
12
|
-
def exceptions
|
13
|
-
@exceptions ||= JSON.parse(File.read("#{ROOT}/data/phono.json"))
|
14
|
-
end
|
15
|
-
|
16
|
-
def conversion
|
17
|
-
@conversion ||= parseCSV "conversion"
|
18
|
-
end
|
19
|
-
|
20
|
-
def apimatch(texte)
|
21
|
-
texte = texte.downcase
|
22
|
-
texte.gsub(SPE, "").split.map do |mot|
|
23
|
-
exceptions[mot] || "".tap do |result|
|
24
|
-
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
25
|
-
mot.sub! /#{regle}/, ""
|
26
|
-
result << api.to_s
|
27
|
-
end until mot.empty?
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def voxbi(texte)
|
33
|
-
paires_dispo = File.open("#{ROOT}/data/paires_disponibles.csv").read.split("\n")
|
34
|
-
api = apimatch(texte).join "_"
|
35
|
-
puts api.inspect
|
36
|
-
fichiers = []
|
37
|
-
while api.length !=0
|
38
|
-
paires_dispo.each do |paires|
|
39
|
-
if api.match(/^#{paires}/)
|
40
|
-
fichiers << "#{ROOT}/data/paires/#{paires}.ogg"
|
41
|
-
api = api.sub(/^#{paires}/,"")
|
42
|
-
break
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
`sox #{fichiers.join(" ")} #{ROOT}/data/paires.wav`
|
47
|
-
`aplay #{ROOT}/data/paires.wav`
|
48
|
-
end
|
49
|
-
|
50
|
-
voxbi(ARGV[0])
|