google_speech 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDY1ODIwZjVkZWExN2NkYzdlYTBkMGMzMzdkMzQ2N2U0M2Q0OTJjYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGRjOTQ2NGFkNDMzZTJhMGEwOTBkOWMxMzE5ODVjZDMyZDBkZDM3Mw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzMxOGYzMTcyMDcwYmNhMTI1OTI4ZWZmZDA0NjlmYmRjNWEzMjBkNjkzYzM5
|
10
|
+
YmMyZjdjZDEyZmIyZDJjNGE1ZmZmODE5ZDBlYWE4ZjQzZWZmMDYyNzY2ZDc3
|
11
|
+
ODQwMTMyZDY3ZGExZGM0ZmY1ZDZmZmNkZjg1ZjdhMWE1ODQ5ZWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTc2ZWVkNTAwNDdiNTQ3OWFmYzY2MGQxYzliYmMzZDVmMjg1MGJjZmZiNGE3
|
14
|
+
NTBiY2RjODM4YzlmZWZjYjRlMWZlM2EzNDE1MWVkZDUxYjRhMmI5Zjg0MjNk
|
15
|
+
MzVhYzhkZDI2ZjJmZjQ3MjU5NWVlYjI3OWU0YmRjMjRiM2NiZDU=
|
data/lib/google_speech/chunk.rb
CHANGED
@@ -9,9 +9,9 @@ module GoogleSpeech
|
|
9
9
|
|
10
10
|
def initialize(original_file, original_duration, start_time, duration)
|
11
11
|
@original_file = original_file
|
12
|
-
@original_duration = original_duration
|
13
|
-
@start_time = start_time
|
14
|
-
@duration = [duration
|
12
|
+
@original_duration = original_duration
|
13
|
+
@start_time = start_time
|
14
|
+
@duration = [duration, (@original_duration - @start_time)].min
|
15
15
|
@chunk_file = Tempfile.new([File.basename(@original_file), '.flac'])
|
16
16
|
# puts "@chunk_file: #{@chunk_file.path}"
|
17
17
|
Utility.trim_to_flac(@original_file.path, @duration, @chunk_file.path, @start_time, @duration)
|
@@ -7,10 +7,10 @@ module GoogleSpeech
|
|
7
7
|
attr_accessor :original_file, :chunk_duration, :overlap
|
8
8
|
|
9
9
|
def initialize(original_file, chunk_duration=8, overlap=1)
|
10
|
-
@chunk_duration = chunk_duration
|
10
|
+
@chunk_duration = chunk_duration
|
11
11
|
@original_file = original_file
|
12
12
|
@overlap = overlap
|
13
|
-
@original_duration = GoogleSpeech::Utility.audio_file_duration(@original_file.path)
|
13
|
+
@original_duration = GoogleSpeech::Utility.audio_file_duration(@original_file.path)
|
14
14
|
end
|
15
15
|
|
16
16
|
# return temp file for each chunk
|
@@ -14,7 +14,7 @@ module GoogleSpeech
|
|
14
14
|
def audio_file_duration(path)
|
15
15
|
check_local_file(path)
|
16
16
|
|
17
|
-
soxi_duration, err = run_command("soxi -V0 -D #{path}", :nice=>false, :echo_return=>false)
|
17
|
+
soxi_duration, err = run_command("soxi -V0 -D '#{path}'", :nice=>false, :echo_return=>false)
|
18
18
|
duration = soxi_duration.chomp.to_f
|
19
19
|
duration
|
20
20
|
end
|
@@ -22,9 +22,9 @@ module GoogleSpeech
|
|
22
22
|
def trim_to_flac(wav_path, duration, flac_path, start, length)
|
23
23
|
check_local_file(wav_path)
|
24
24
|
|
25
|
-
command = "sox -t wav '#{wav_path}' -r 16000 -c 1 -t flac '#{flac_path}' trim #{start
|
25
|
+
command = "sox -t wav '#{wav_path}' -r 16000 -c 1 -t flac '#{flac_path}' trim #{start} #{length} compand .5,2 -80,-80,-75,-50,-30,-15,0,0 norm -0.1"
|
26
26
|
|
27
|
-
# command = "sox -t wav '#{wav_path}' -t flac '#{flac_path}' trim #{start
|
27
|
+
# command = "sox -t wav '#{wav_path}' -t flac '#{flac_path}' trim #{start} #{length} rate 16k"
|
28
28
|
|
29
29
|
out, err = run_command(command)
|
30
30
|
response = out + err
|