fest 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +218 -0
- data/Gemfile +4 -0
- data/MIT-license.org +20 -0
- data/README.org +75 -0
- data/changelog.org +2 -0
- data/fest.gemspec +15 -0
- data/lib/fest.rb +93 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 26bd6841d465bbe3da0c87f3c473e13bf6d7afee
|
4
|
+
data.tar.gz: 02b0687457ae5db2c201f6e96bc49c201045fbdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1cf3e7b19e6543c119c978e11b7118e610b221004c803b57f28228d3d63b95686d5d8beccaa568cb373fb0f8ccf013a4c77c870631e10713b1e565bf39631056
|
7
|
+
data.tar.gz: 09debce496ac1be78a4a596c6b97f05cf6a0916efc9da8eb898e022d96b7fb10fa8322115df4581b7c837160529f6549f3f953ce958af37f4e1e9932e87d4792
|
data/.gitignore
ADDED
@@ -0,0 +1,218 @@
|
|
1
|
+
o#################
|
2
|
+
## Eclipse
|
3
|
+
#################
|
4
|
+
|
5
|
+
*.pydevproject
|
6
|
+
.project
|
7
|
+
.metadata
|
8
|
+
bin/
|
9
|
+
tmp/
|
10
|
+
*.tmp
|
11
|
+
*.bak
|
12
|
+
*.swp
|
13
|
+
*~.nib
|
14
|
+
local.properties
|
15
|
+
.classpath
|
16
|
+
.settings/
|
17
|
+
.loadpath
|
18
|
+
|
19
|
+
# External tool builders
|
20
|
+
.externalToolBuilders/
|
21
|
+
|
22
|
+
# Locally stored "Eclipse launch configurations"
|
23
|
+
*.launch
|
24
|
+
|
25
|
+
# CDT-specific
|
26
|
+
.cproject
|
27
|
+
|
28
|
+
# PDT-specific
|
29
|
+
.buildpath
|
30
|
+
|
31
|
+
|
32
|
+
#################
|
33
|
+
## Visual Studio
|
34
|
+
#################
|
35
|
+
|
36
|
+
## Ignore Visual Studio temporary files, build results, and
|
37
|
+
## files generated by popular Visual Studio add-ons.
|
38
|
+
|
39
|
+
# User-specific files
|
40
|
+
*.suo
|
41
|
+
*.user
|
42
|
+
*.sln.docstates
|
43
|
+
|
44
|
+
# Build results
|
45
|
+
|
46
|
+
[Dd]ebug/
|
47
|
+
[Rr]elease/
|
48
|
+
x64/
|
49
|
+
build/
|
50
|
+
[Bb]in/
|
51
|
+
[Oo]bj/
|
52
|
+
|
53
|
+
# MSTest test Results
|
54
|
+
[Tt]est[Rr]esult*/
|
55
|
+
[Bb]uild[Ll]og.*
|
56
|
+
|
57
|
+
*_i.c
|
58
|
+
*_p.c
|
59
|
+
*.ilk
|
60
|
+
*.meta
|
61
|
+
*.obj
|
62
|
+
*.pch
|
63
|
+
*.pdb
|
64
|
+
*.pgc
|
65
|
+
*.pgd
|
66
|
+
*.rsp
|
67
|
+
*.sbr
|
68
|
+
*.tlb
|
69
|
+
*.tli
|
70
|
+
*.tlh
|
71
|
+
*.tmp
|
72
|
+
*.tmp_proj
|
73
|
+
*.log
|
74
|
+
*.vspscc
|
75
|
+
*.vssscc
|
76
|
+
.builds
|
77
|
+
*.pidb
|
78
|
+
*.log
|
79
|
+
*.scc
|
80
|
+
|
81
|
+
# Visual C++ cache files
|
82
|
+
ipch/
|
83
|
+
*.aps
|
84
|
+
*.ncb
|
85
|
+
*.opensdf
|
86
|
+
*.sdf
|
87
|
+
*.cachefile
|
88
|
+
|
89
|
+
# Visual Studio profiler
|
90
|
+
*.psess
|
91
|
+
*.vsp
|
92
|
+
*.vspx
|
93
|
+
|
94
|
+
# Guidance Automation Toolkit
|
95
|
+
*.gpState
|
96
|
+
|
97
|
+
# ReSharper is a .NET coding add-in
|
98
|
+
_ReSharper*/
|
99
|
+
*.[Rr]e[Ss]harper
|
100
|
+
|
101
|
+
# TeamCity is a build add-in
|
102
|
+
_TeamCity*
|
103
|
+
|
104
|
+
# DotCover is a Code Coverage Tool
|
105
|
+
*.dotCover
|
106
|
+
|
107
|
+
# NCrunch
|
108
|
+
*.ncrunch*
|
109
|
+
.*crunch*.local.xml
|
110
|
+
|
111
|
+
# Installshield output folder
|
112
|
+
[Ee]xpress/
|
113
|
+
|
114
|
+
# DocProject is a documentation generator add-in
|
115
|
+
DocProject/buildhelp/
|
116
|
+
DocProject/Help/*.HxT
|
117
|
+
DocProject/Help/*.HxC
|
118
|
+
DocProject/Help/*.hhc
|
119
|
+
DocProject/Help/*.hhk
|
120
|
+
DocProject/Help/*.hhp
|
121
|
+
DocProject/Help/Html2
|
122
|
+
DocProject/Help/html
|
123
|
+
|
124
|
+
# Click-Once directory
|
125
|
+
publish/
|
126
|
+
|
127
|
+
# Publish Web Output
|
128
|
+
*.Publish.xml
|
129
|
+
*.pubxml
|
130
|
+
|
131
|
+
# NuGet Packages Directory
|
132
|
+
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
|
133
|
+
#packages/
|
134
|
+
|
135
|
+
# Windows Azure Build Output
|
136
|
+
csx
|
137
|
+
*.build.csdef
|
138
|
+
|
139
|
+
# Windows Store app package directory
|
140
|
+
AppPackages/
|
141
|
+
|
142
|
+
# Others
|
143
|
+
sql/
|
144
|
+
*.Cache
|
145
|
+
ClientBin/
|
146
|
+
[Ss]tyle[Cc]op.*
|
147
|
+
~$*
|
148
|
+
*~
|
149
|
+
*.dbmdl
|
150
|
+
*.[Pp]ublish.xml
|
151
|
+
*.pfx
|
152
|
+
*.publishsettings
|
153
|
+
|
154
|
+
# RIA/Silverlight projects
|
155
|
+
Generated_Code/
|
156
|
+
|
157
|
+
# Backup & report files from converting an old project file to a newer
|
158
|
+
# Visual Studio version. Backup files are not needed, because we have git ;-)
|
159
|
+
_UpgradeReport_Files/
|
160
|
+
Backup*/
|
161
|
+
UpgradeLog*.XML
|
162
|
+
UpgradeLog*.htm
|
163
|
+
|
164
|
+
# SQL Server files
|
165
|
+
App_Data/*.mdf
|
166
|
+
App_Data/*.ldf
|
167
|
+
|
168
|
+
#############
|
169
|
+
## Windows detritus
|
170
|
+
#############
|
171
|
+
|
172
|
+
# Windows image file caches
|
173
|
+
Thumbs.db
|
174
|
+
ehthumbs.db
|
175
|
+
|
176
|
+
# Folder config file
|
177
|
+
Desktop.ini
|
178
|
+
|
179
|
+
# Recycle Bin used on file shares
|
180
|
+
$RECYCLE.BIN/
|
181
|
+
|
182
|
+
# Mac crap
|
183
|
+
.DS_Store
|
184
|
+
|
185
|
+
|
186
|
+
#############
|
187
|
+
## Python
|
188
|
+
#############
|
189
|
+
|
190
|
+
*.py[co]
|
191
|
+
|
192
|
+
# Packages
|
193
|
+
*.egg
|
194
|
+
*.egg-info
|
195
|
+
dist/
|
196
|
+
build/
|
197
|
+
eggs/
|
198
|
+
parts/
|
199
|
+
var/
|
200
|
+
sdist/
|
201
|
+
develop-eggs/
|
202
|
+
.installed.cfg
|
203
|
+
|
204
|
+
# Installer logs
|
205
|
+
pip-log.txt
|
206
|
+
|
207
|
+
# Unit test / coverage reports
|
208
|
+
.coverage
|
209
|
+
.tox
|
210
|
+
|
211
|
+
#Translations
|
212
|
+
*.mo
|
213
|
+
|
214
|
+
#Mr Developer
|
215
|
+
.mr.developer.cfg
|
216
|
+
|
217
|
+
# my
|
218
|
+
*.*~
|
data/Gemfile
ADDED
data/MIT-license.org
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014-2015 Alexsey Ermolaev
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.org
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
** FEST
|
2
|
+
FEST - Ruby-адаптер, использующий [[https://wiki.archlinux.org/index.php/Festival_%28%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%29][Festival]], для озвучки текста и скриптов...
|
3
|
+
** Установка
|
4
|
+
Требуется установить [[https://wiki.archlinux.org/index.php/Festival_%28%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9%29][Festival]] и нужные языки...
|
5
|
+
#+begin_src ruby
|
6
|
+
# Gemfile
|
7
|
+
gem 'fest'
|
8
|
+
#+end_src
|
9
|
+
или
|
10
|
+
#+begin_src ruby
|
11
|
+
$ gem install fest
|
12
|
+
#+end_src
|
13
|
+
** Использование
|
14
|
+
***** Вызов методов
|
15
|
+
#+begin_src ruby
|
16
|
+
# Подключаем
|
17
|
+
require 'fest'
|
18
|
+
|
19
|
+
@fest = Fest.new
|
20
|
+
text = "Пример"
|
21
|
+
@fest.say(text)
|
22
|
+
# => Произнесёт "Пример"
|
23
|
+
|
24
|
+
# Расширенный вариант
|
25
|
+
params = {:lang => "(cmu_us_slt_arctic_hts)", :volume => 60}
|
26
|
+
text = "This is an example"
|
27
|
+
@fest.say(text, params)
|
28
|
+
# => Произнесёт "This is an example" поставив 60% громкости...
|
29
|
+
|
30
|
+
# Все параметры
|
31
|
+
# params || default value
|
32
|
+
params[:data] || "/tmp"
|
33
|
+
params[:volume] || 70
|
34
|
+
params[:sound] || "alsa"
|
35
|
+
params[:lang] || "(voice_msu_ru_nsh_clunits)"
|
36
|
+
|
37
|
+
# Склонение
|
38
|
+
num = 2
|
39
|
+
arr = ["Сообщение", "Сообщения", "Сообщений"]
|
40
|
+
text = @fest.pluraform(num, arr)
|
41
|
+
puts text
|
42
|
+
# => "Сообщения"
|
43
|
+
#+end_src
|
44
|
+
|
45
|
+
** Кастомизация
|
46
|
+
#+begin_src ruby
|
47
|
+
@fest.init(params={})
|
48
|
+
# Узнает текущую громкость... @data, @i ...
|
49
|
+
|
50
|
+
@fest.check_light # (with xbacklight)
|
51
|
+
# Проверяет яркость не равна ли нулю... если равна выходит...
|
52
|
+
# Можно сделать свою проверку ...
|
53
|
+
|
54
|
+
@fest.check_say_wav
|
55
|
+
# Проверяем на max @i ... если нету @i = 1 ...
|
56
|
+
# Требуется чтобы сообщения не затирались до проигрывания...
|
57
|
+
|
58
|
+
@fest.make_wav(text)
|
59
|
+
# Создаём wav с определённым языком ... с учётом @i...
|
60
|
+
|
61
|
+
@fest.set_volume(params={})
|
62
|
+
# Ставит оптимальную громкость с учётом звуковой системы...
|
63
|
+
|
64
|
+
@fest.expect_if_aplay_now
|
65
|
+
# Ожидает, если проигрывается сообщение ...
|
66
|
+
|
67
|
+
@fest.play_wav
|
68
|
+
# Проигрывает wav ...
|
69
|
+
|
70
|
+
@fest.return_current_volume(params={})
|
71
|
+
# Возращает громкость до проигрывания ...
|
72
|
+
|
73
|
+
@fest.delete_wav
|
74
|
+
# Удаляет проигранный файл ...
|
75
|
+
#+end_src
|
data/changelog.org
ADDED
data/fest.gemspec
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "fest"
|
3
|
+
s.version = "0.0.2"
|
4
|
+
s.authors = ["Alexsey Ermolaev"]
|
5
|
+
s.email = %q{afay.zangetsu@gmail.com}
|
6
|
+
s.homepage = %q{https://github.com/AfsmNGhr/fest}
|
7
|
+
s.description = %q{Ruby wrapper for festival scripts}
|
8
|
+
s.summary = %q{Ruby wrapper for festival speech engine}
|
9
|
+
s.license = 'MIT'
|
10
|
+
|
11
|
+
s.files = `git ls-files`.split("\n")
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
|
14
|
+
s.requirements << 'Festival speech engine'
|
15
|
+
end
|
data/lib/fest.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
class Fest
|
4
|
+
|
5
|
+
def say(str, params={})
|
6
|
+
init(params={})
|
7
|
+
check_light
|
8
|
+
@i = check_say_wav
|
9
|
+
make_wav(str, params={})
|
10
|
+
set_volume(params={})
|
11
|
+
expect_if_aplay_now
|
12
|
+
play_wav
|
13
|
+
return_current_volume(params={})
|
14
|
+
delete_wav
|
15
|
+
end
|
16
|
+
|
17
|
+
def init(params={})
|
18
|
+
@data = params[:data] || "/tmp"
|
19
|
+
@current_volume = `amixer | grep -o [0-9]* | sed "5 ! d"`.to_i
|
20
|
+
@i = `ls -r #{@data} | grep -o [0-9]* | sed "1 ! d"`.to_i
|
21
|
+
end
|
22
|
+
|
23
|
+
def check_light
|
24
|
+
light = `xbacklight`.to_i
|
25
|
+
exit if light == 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def check_say_wav
|
29
|
+
if @i > 0
|
30
|
+
@i += 1
|
31
|
+
else
|
32
|
+
@i = 1
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def make_wav(str, params={})
|
37
|
+
lang = params[:lang] || "(voice_msu_ru_nsh_clunits)"
|
38
|
+
system("echo '#{str}' | text2wave -o #{@data}/say_#{@i}.wav \
|
39
|
+
-eval '#{lang}' > /dev/null 2>&1")
|
40
|
+
end
|
41
|
+
|
42
|
+
def set_volume(params={})
|
43
|
+
volume = params[:volume] || 70
|
44
|
+
sound = params[:sound] || "alsa"
|
45
|
+
set_volume_sound_system(volume, params={})
|
46
|
+
end
|
47
|
+
|
48
|
+
def expect_if_aplay_now
|
49
|
+
while true
|
50
|
+
sleep 1
|
51
|
+
break if `ps -el | grep aplay | wc -l`.to_i == 0
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def play_wav
|
56
|
+
system("aplay #{@data}/say_#{@i}.wav > /dev/null 2>&1")
|
57
|
+
end
|
58
|
+
|
59
|
+
def return_current_volume(params={})
|
60
|
+
if `ps -el | grep aplay | wc -l`.to_i == 0
|
61
|
+
set_volume_sound_system(@current_volume, params={})
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def set_volume_sound_system(volume, params={})
|
66
|
+
sound = params[:sound] || "alsa"
|
67
|
+
if sound == "alsa"
|
68
|
+
system("amixer set Master #{volume}% > /dev/null 2>&1")
|
69
|
+
else
|
70
|
+
system("amixer -D pulse set Master #{volume}% > /dev/null 2>&1")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def delete_wav
|
75
|
+
system("rm -f #{@data}/say_#{@i}.wav")
|
76
|
+
end
|
77
|
+
|
78
|
+
def pluralform(num, arr)
|
79
|
+
n = num % 100
|
80
|
+
m = n % 10
|
81
|
+
|
82
|
+
if n > 10 && n < 20
|
83
|
+
return arr[2]
|
84
|
+
elsif m > 1 && m < 5
|
85
|
+
return arr[1]
|
86
|
+
elsif m == 1
|
87
|
+
return arr[0]
|
88
|
+
else
|
89
|
+
return arr[2]
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fest
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexsey Ermolaev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-12-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Ruby wrapper for festival scripts
|
14
|
+
email: afay.zangetsu@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- ".gitignore"
|
20
|
+
- Gemfile
|
21
|
+
- MIT-license.org
|
22
|
+
- README.org
|
23
|
+
- changelog.org
|
24
|
+
- fest.gemspec
|
25
|
+
- lib/fest.rb
|
26
|
+
homepage: https://github.com/AfsmNGhr/fest
|
27
|
+
licenses:
|
28
|
+
- MIT
|
29
|
+
metadata: {}
|
30
|
+
post_install_message:
|
31
|
+
rdoc_options: []
|
32
|
+
require_paths:
|
33
|
+
- lib
|
34
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
requirements:
|
45
|
+
- Festival speech engine
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.2.2
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Ruby wrapper for festival speech engine
|
51
|
+
test_files: []
|
52
|
+
has_rdoc:
|