jumping_words 0.2.2 → 0.3.0
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 +4 -4
- data/README.rdoc +30 -10
- data/bin/jwords +68 -19
- data/config.rb +7 -1
- data/lib/jwords/db_words.rb +1 -3
- data/lib/jwords/say_words.rb +42 -18
- data/lib/jwords/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d199af8b2036ffcecbf92972854db0c3416ffc49
|
4
|
+
data.tar.gz: e5dff6a63542450915ab3ee205d97c2b3b2f92e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92edfbc425f21b5321ebec92976aa0527f93307fb1b0903ae033b11d04a948402050d2d333d5c4b30cf2882196d18ee8bc9d1ae6d0749bcb77283ab8626ba4cd
|
7
|
+
data.tar.gz: 02943d04bfa6ca7bf864b22167b507d5fd902a99883352427e66a38a32345a3ed7dfebb16ee7d5868f3cd03a5ed05506b3bb9a018ab5d107c06eac0065e88b29
|
data/README.rdoc
CHANGED
@@ -1,35 +1,55 @@
|
|
1
1
|
= Jumping Words
|
2
|
-
The program
|
3
|
-
|
4
|
-
|
2
|
+
The program speaks and displays in the pop-up window the word or phrase and the word's translation or phrase.
|
3
|
+
After end of list back to the start.
|
4
|
+
|
5
|
+
Supports OS MAC OS X 10.8 or higher or Ubuntu
|
5
6
|
|
6
7
|
== Dependencies
|
7
8
|
For linux
|
8
9
|
sudo apt-get install libnotify-bin
|
9
10
|
|
10
|
-
|
11
|
+
On MAC OS X before you start, you should add to your system the voices for words and translates.
|
12
|
+
To enable the speech recognition ability and use speech commands on your Mac, the first thing you have to do is open the Speech menu from System Preferences.
|
13
|
+
|
14
|
+
For example for Russian you should install the Milena voice.
|
15
|
+
|
16
|
+
== Config
|
17
|
+
Default:
|
18
|
+
Show message: true
|
19
|
+
Timeout between a word and translate: 3 sec.
|
20
|
+
Timeout to start list: 10 sec.
|
21
|
+
MAC OS X word voice: Vicki.
|
22
|
+
MAC OS X translate voice: Milena.
|
11
23
|
|
24
|
+
More:
|
25
|
+
jwords -h
|
12
26
|
|
13
27
|
== Actions
|
14
28
|
Starting
|
15
|
-
jwords
|
29
|
+
jwords start
|
30
|
+
or
|
31
|
+
jwords -v Fiona -t Milena -i5 start
|
16
32
|
|
17
33
|
Stoping
|
18
34
|
ctrl+c
|
19
35
|
|
20
36
|
View a list of words
|
21
|
-
jwords
|
37
|
+
jwords list
|
22
38
|
|
23
|
-
1
|
24
|
-
2
|
25
|
-
3
|
39
|
+
1 convenient: удобный | 7
|
40
|
+
2 If I were you: на твоем месте | 6
|
41
|
+
3 in turns: по очереди | 5
|
42
|
+
4 endurance: выносливость | 2
|
43
|
+
5 spoil, spoilt, spoilt: портиться, испортилось | 2
|
44
|
+
6 to lead, led, led: приводить, привели | 2
|
45
|
+
7 to achieve: достигать | 2
|
26
46
|
...
|
27
47
|
|
28
48
|
Adding words to the database
|
29
49
|
jwords -a root: корень
|
30
50
|
jwords -a to play: играть
|
31
51
|
|
32
|
-
Delete a word from the database (indicated by the index of the word)
|
52
|
+
Delete a word from the database (indicated by the index of the word in the list)
|
33
53
|
jwords -d 1
|
34
54
|
|
35
55
|
If you want to change words in directly in CSV find .jwords directory in your home directory, then open jumping_words_db.csv. After saving the file restart the script.
|
data/bin/jwords
CHANGED
@@ -1,13 +1,47 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# encoding: utf-8
|
3
3
|
require 'optparse'
|
4
|
+
require 'ostruct'
|
4
5
|
require 'pp'
|
5
6
|
|
6
7
|
$:.push File.expand_path("../../lib", __FILE__)
|
7
8
|
require 'jumping_words'
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
include OS
|
11
|
+
|
12
|
+
options = OpenStruct.new
|
13
|
+
options.message = SHOW_MESSAGE
|
14
|
+
options.space_words = SPACE_WORDS
|
15
|
+
options.space_interation = SPACE_INTERATION
|
16
|
+
options.mac_word_voice = MAC_WORD_VOICE
|
17
|
+
options.mac_translate_voice = MAC_TRANSLATE_VOICE
|
18
|
+
options.repeat = REPEAT
|
19
|
+
|
20
|
+
optparse = OptionParser.new do |opts|
|
21
|
+
|
22
|
+
opts.on( '-n', '--no-message', 'No display message' ) do
|
23
|
+
options.message = false
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on( '-r', '--repeat [TIMES]', Integer, "How many times repeat each word in the cycle. Default: #{REPEAT}" ) do |times|
|
27
|
+
options.repeat = times
|
28
|
+
end
|
29
|
+
|
30
|
+
opts.on( '-w', '--timeout-words [SPACE]', Integer, "Timeout between the word and translate. Default: #{SPACE_WORDS}" ) do |space_words|
|
31
|
+
options.space_words = space_words
|
32
|
+
end
|
33
|
+
|
34
|
+
opts.on( '-i', '--timeout-interation [SPACE]', Integer, "Timeout an each interation. Default: #{SPACE_INTERATION}" ) do |space_interation|
|
35
|
+
options.space_interation = space_interation
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on( '-v', '--mac-word-voice [VOICE]', String, "MAC OS X word voice" ) do |voice|
|
39
|
+
options.mac_word_voice = voice
|
40
|
+
end
|
41
|
+
|
42
|
+
opts.on( '-t', '--mac-translate-voice [VOICE]', String, "MAC OS X translate voice" ) do |voice|
|
43
|
+
options.mac_translate_voice = voice
|
44
|
+
end
|
11
45
|
|
12
46
|
#The command addes a word
|
13
47
|
opts.on( '-a', '--add', 'Add the word' ) do
|
@@ -33,25 +67,40 @@ optparse = OptionParser.new do|opts|
|
|
33
67
|
end
|
34
68
|
end
|
35
69
|
|
36
|
-
#The list of words
|
37
|
-
opts.on( '-l', '--list', 'List of words' ) do
|
38
|
-
db = DbWords.new
|
39
|
-
db.list
|
40
|
-
exit
|
41
|
-
end
|
42
|
-
|
43
|
-
#run the application
|
44
|
-
opts.on( '-s', '--start', 'Start of app' ) do
|
45
|
-
db = DbWords.new
|
46
|
-
app = SayWords.new(:show_message => SHOW_MESSAGE, :space_words => SPACE_WORDS, :space_interation => SPACE_INTERATION)
|
47
70
|
|
48
|
-
begin
|
49
|
-
app.run
|
50
|
-
rescue Interrupt
|
51
|
-
puts "Exiting..."
|
52
|
-
end
|
53
|
-
end
|
54
71
|
|
55
72
|
end
|
56
73
|
|
57
74
|
optparse.parse!
|
75
|
+
|
76
|
+
puts "Show message: #{options.message}"
|
77
|
+
puts "Timeout between a word and translate: #{options.space_words} sec."
|
78
|
+
puts "Timeout to start list: #{options.space_interation} sec."
|
79
|
+
if mac?
|
80
|
+
puts "MAC OS X word voice: #{options.mac_word_voice}."
|
81
|
+
puts "MAC OS X translate voice: #{options.mac_translate_voice}."
|
82
|
+
end
|
83
|
+
|
84
|
+
puts "How many times repeat each word in the cycle: #{options.repeat}"
|
85
|
+
|
86
|
+
#run the application
|
87
|
+
if ARGV.first == 'start'
|
88
|
+
db = DbWords.new
|
89
|
+
app = SayWords.new(:show_message => options.message, :space_words => options.space_words,
|
90
|
+
:space_interation => options.space_interation, :mac_word_voice => options.mac_word_voice,
|
91
|
+
:mac_translate_voice => options.mac_translate_voice, :repeat => options.repeat )
|
92
|
+
|
93
|
+
begin
|
94
|
+
app.run
|
95
|
+
rescue Interrupt
|
96
|
+
puts "Exiting..."
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
#The list of words
|
102
|
+
if ARGV.first == 'list'
|
103
|
+
db = DbWords.new
|
104
|
+
db.list
|
105
|
+
exit
|
106
|
+
end
|
data/config.rb
CHANGED
@@ -3,8 +3,14 @@ DATABASE = "jumping_words_db"
|
|
3
3
|
# Database directory
|
4
4
|
DATABASE_DIR = ".jwords"
|
5
5
|
# space between word and translate
|
6
|
-
SPACE_WORDS =
|
6
|
+
SPACE_WORDS = 2
|
7
7
|
# space iteration
|
8
8
|
SPACE_INTERATION = 10
|
9
9
|
#show message box true or false
|
10
10
|
SHOW_MESSAGE = true
|
11
|
+
#MAC OS X word voice
|
12
|
+
MAC_WORD_VOICE = 'Vicki'
|
13
|
+
#MAC OS X translate voice
|
14
|
+
MAC_TRANSLATE_VOICE = 'Milena'
|
15
|
+
#how many times repeat each word in the cycle
|
16
|
+
REPEAT = 1
|
data/lib/jwords/db_words.rb
CHANGED
@@ -60,14 +60,12 @@ class DbWords
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
64
|
-
GC.start
|
65
63
|
end
|
66
64
|
|
67
65
|
#Print the list of words
|
68
66
|
def list
|
69
67
|
list_of_words do |word, idx|
|
70
|
-
puts "#{idx + 1} #{word[0]}
|
68
|
+
puts "#{idx + 1} #{word[0]}: #{word[1]} | #{word[2]}"
|
71
69
|
end
|
72
70
|
end
|
73
71
|
|
data/lib/jwords/say_words.rb
CHANGED
@@ -4,9 +4,12 @@ class SayWords
|
|
4
4
|
def initialize(options={})
|
5
5
|
@db = DbWords.new
|
6
6
|
@collection = @db.collection
|
7
|
-
@show_message = options[:show_message]
|
7
|
+
@show_message = options[:show_message].nil? ? SHOW_MESSAGE : options[:show_message]
|
8
8
|
@space_words = options[:space_words] || SPACE_WORDS
|
9
9
|
@space_interation = options[:space_interation] || SPACE_INTERATION
|
10
|
+
@mac_word_voice = options[:mac_word_voice] || MAC_WORD_VOICE
|
11
|
+
@mac_translate_voice = options[:mac_translate_voice] || MAC_TRANSLATE_VOICE
|
12
|
+
@repeat = options[:repeat] || REPEAT
|
10
13
|
end
|
11
14
|
|
12
15
|
def run
|
@@ -21,39 +24,60 @@ class SayWords
|
|
21
24
|
def do_ubuntu
|
22
25
|
loop do
|
23
26
|
@collection.each_with_index do |word, idx|
|
24
|
-
|
25
|
-
|
26
|
-
system 'espeak -v en -s120 "'+ word[0] +'"'
|
27
|
-
sleep @space_words
|
28
|
-
#puts "I say #{word[1]}"
|
29
|
-
system 'espeak -v ru -s120 "'+ word[1] +'"'
|
27
|
+
rep_times = !word[2].nil? ? word[2].to_i : 1
|
28
|
+
@repeat.times do
|
30
29
|
|
31
|
-
|
32
|
-
@db.update(idx, [word[0], word[1], !word[2].nil? ? word[2].to_i + 1 : 1])
|
30
|
+
rep_times += 1
|
33
31
|
|
32
|
+
puts "#{word[0]}: #{word[1]} | #{rep_times}"
|
33
|
+
system 'notify-send -i /usr/share/pixmaps/gnome-irc.png "'+ word[0] +'" "'+ word[1] +'" -t 1' if @show_message
|
34
|
+
system 'espeak -v en -s120 "'+ word[0] +'"'
|
35
|
+
sleep @space_words
|
36
|
+
|
37
|
+
system 'espeak -v ru -s120 "'+ word[1] +'"'
|
38
|
+
|
39
|
+
#set number of showing
|
40
|
+
@db.update(idx, [word[0], word[1], rep_times])
|
41
|
+
|
42
|
+
sleep @space_words
|
43
|
+
end
|
34
44
|
sleep @space_interation
|
35
45
|
end
|
36
46
|
sleep 4 # for notification hiding
|
47
|
+
|
48
|
+
#cleaning
|
49
|
+
GC.start
|
37
50
|
end
|
38
51
|
end
|
39
52
|
|
40
53
|
def do_mac
|
41
54
|
loop do
|
42
55
|
@collection.each_with_index do |word, idx|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
sleep @space_words
|
48
|
-
#puts "I say #{word[1]}"
|
49
|
-
system 'say -v Milena "'+ word[1] +'"'
|
56
|
+
rep_times = !word[2].nil? ? word[2].to_i : 1
|
57
|
+
@repeat.times do
|
58
|
+
|
59
|
+
rep_times += 1
|
50
60
|
|
51
|
-
|
52
|
-
@db.update(idx, [word[0], word[1], !word[2].nil? ? word[2].to_i + 1 : 1])
|
61
|
+
puts "#{word[0]}: #{word[1]} | #{rep_times}"
|
53
62
|
|
63
|
+
system 'terminal-notifier -message "'+ word[0] +': '+ word[1] +'" -title ""' if @show_message
|
64
|
+
system 'say -v ' + @mac_word_voice + ' "'+ word[0] +'"'
|
65
|
+
|
66
|
+
sleep @space_words
|
67
|
+
|
68
|
+
system 'say -v '+ @mac_translate_voice +' "'+ word[1] +'"'
|
69
|
+
|
70
|
+
#set number of showing
|
71
|
+
@db.update(idx, [word[0], word[1], rep_times])
|
72
|
+
|
73
|
+
sleep @space_words
|
74
|
+
end
|
54
75
|
sleep @space_interation
|
55
76
|
end
|
56
77
|
sleep 4 # for notification hiding
|
78
|
+
|
79
|
+
#cleaning
|
80
|
+
GC.start
|
57
81
|
end
|
58
82
|
|
59
83
|
end
|
data/lib/jwords/version.rb
CHANGED