rubysounds 0.4 → 0.5

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rubysounds.rb +25 -8
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 677bcb73d8594a5fab7092c4852cfe94178d6b9f
4
- data.tar.gz: 2b18a5e8809be35049129cef5a039c513022ccf0
3
+ metadata.gz: a5fc8715d53adfff02a385b6ca1888918992d271
4
+ data.tar.gz: 4ea47deb47221f63360b7624015978510680f90b
5
5
  SHA512:
6
- metadata.gz: 84ded87b8c1c86c0b0935bb03043b267a0cf9e0698ba2bd7a3eb3ff658834144ad5ac691185834dc16681bf7cf316e431359a654221a733501bb3339f4769d4c
7
- data.tar.gz: 35b8d51c69a4404c861d40b7f4ae69642b7a6df13af81e475ce1a30c88673e3173c6f29731680017535dfe5aaee5441d58c5e4d7cbbb4d2a0ff584ab9b2bb3a3
6
+ metadata.gz: 2b33d16c6cf3d68d5e150650f16475d715064905a00ca1b7d4013fac7d3e58dfacdec1acad6262a0b897391e45c1906c2095b65c933e1c521a93883d06c6c6ec
7
+ data.tar.gz: 898f2b9da6795c89fd0106e7d24f362063db2f8020fd7a2a2daeceae9e9d6bc1996337012069d1fff66cdf023ce1de97e5e4491c375be686778cb7ed6bd9ba91
data/lib/rubysounds.rb CHANGED
@@ -95,8 +95,7 @@ end
95
95
  # Array to store VLC sound processes
96
96
  $children_sounds = Array.new
97
97
 
98
- # Catching CTRL-C Keyboard Interrupt signal
99
- trap "SIGINT" do
98
+ def killallsounds
100
99
  puts "Exiting"
101
100
  # Kill all children sounds
102
101
  for child_sound in $children_sounds
@@ -116,8 +115,17 @@ trap "SIGINT" do
116
115
  exit 130
117
116
  end
118
117
 
118
+ # Catching CTRL-C Keyboard Interrupt signal
119
+ Signal.trap('INT') do
120
+ killallsounds
121
+ end
122
+ # Catching QUIT signal
123
+ Signal.trap('TERM') do
124
+ killallsounds
125
+ end
126
+
119
127
 
120
- def vlcplay(target, wait: true, bg: false, dummy: true)
128
+ def play(target, wait: true, bg: true, dummy: true, volume: 100, loop: false)
121
129
 
122
130
  # VLC command options
123
131
  if $operative_system == "win"
@@ -135,6 +143,15 @@ def vlcplay(target, wait: true, bg: false, dummy: true)
135
143
  vlccmd = "cvlc --play-and-exit "
136
144
  end
137
145
 
146
+ vlccmd += "--directx-volume " + (volume.to_f/100).to_s + " "
147
+
148
+ if loop
149
+ vlccmd += "--loop "
150
+ end
151
+
152
+ # DEBUG ONLY
153
+ #puts(vlccmd)
154
+
138
155
  io = IO.popen(vlccmd + target)
139
156
  $children_sounds.push(io)
140
157
  # Wait for the sound to end option
@@ -148,9 +165,9 @@ def vlcplay(target, wait: true, bg: false, dummy: true)
148
165
  end
149
166
 
150
167
 
151
- def speak(text, language: "en", wait: true, bg: true)
168
+ def speak(text, language: "en", wait: true, bg: true, volume: 100, loop: false)
152
169
  Speech.new(text, language).save("temp.wav")
153
- vlcplay("temp.wav", wait: wait, bg: bg)
170
+ play("temp.wav", wait: wait, bg: bg, volume: volume, loop: loop)
154
171
  File.delete("temp.wav")
155
172
  end
156
173
 
@@ -161,9 +178,9 @@ def dub(text)
161
178
  end
162
179
 
163
180
 
164
- def play(path, wait: true, bg: true)
165
- vlcplay(path, wait: wait, bg: bg)
166
- end
181
+ #def play(path, wait: true, bg: true, volume: 100, loop: false)
182
+ #play(path, wait: wait, bg: bg, volume: volume, loop: loop)
183
+ #end
167
184
 
168
185
 
169
186
  # Windows-specific methods
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysounds
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.4'
4
+ version: '0.5'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alessandro Norfo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-14 00:00:00.000000000 Z
11
+ date: 2017-10-24 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Ruby library to manage sounds using Google Translate & command line VLC.
13
+ description: Ruby library to manage sounds using Google Translate & VLC.
14
14
  email: ale.norfo@gmail.com
15
15
  executables: []
16
16
  extensions: []