google_speech 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/google_speech/chunk.rb +3 -1
- data/lib/google_speech/transcriber.rb +1 -0
- data/lib/google_speech/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: 469b1c22ae469fdf3d7d0877455bb36a08d65475
|
4
|
+
data.tar.gz: 8a926d4d14f29c329d629c6b489d078a536c2b03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b47651a2503f10d7c21dc803af0fed8879fa8071b064b6c6476288b5d5829722b70bbdf7c52220f426d238d76f28efb10c49c552ff50b95511397523747f8b74
|
7
|
+
data.tar.gz: ffa05213e7ba7f28c5ca3a29e42a68aaebcb541742b3eac3e09d72ccba60e54f7b1558f40757dcd5bec2b1c7241b33fa20a008510105a3ca4f05db4277a2dff2
|
data/lib/google_speech/chunk.rb
CHANGED
@@ -8,12 +8,14 @@ module GoogleSpeech
|
|
8
8
|
attr_accessor :original_file, :original_duration, :start_time, :duration, :chunk_file, :rate
|
9
9
|
|
10
10
|
def initialize(original_file, original_duration, start_time, duration, rate)
|
11
|
+
FileUtils.mkdir_p(GoogleSpeech::TMP_FILE_DIR) unless File.exists?(GoogleSpeech::TMP_FILE_DIR)
|
12
|
+
|
11
13
|
@original_file = original_file
|
12
14
|
@original_duration = original_duration
|
13
15
|
@start_time = start_time
|
14
16
|
@duration = [duration, (@original_duration - @start_time)].min
|
15
17
|
@rate = rate
|
16
|
-
@chunk_file = Tempfile.new([File.basename(@original_file), '.wav'])
|
18
|
+
@chunk_file = Tempfile.new([File.basename(@original_file), '.wav'], GoogleSpeech::TMP_FILE_DIR)
|
17
19
|
# puts "@chunk_file: #{@chunk_file.path}"
|
18
20
|
Utility.trim_and_encode(@original_file.path, @chunk_file.path, @start_time, @duration, @rate)
|
19
21
|
end
|
@@ -35,6 +35,7 @@ module GoogleSpeech
|
|
35
35
|
def open_working_file
|
36
36
|
Utility.check_local_file(@original_file.path)
|
37
37
|
wf_path = random_file_name(@original_file.path)
|
38
|
+
FileUtils.mkdir_p(GoogleSpeech::TMP_FILE_DIR) unless File.exists?(GoogleSpeech::TMP_FILE_DIR)
|
38
39
|
FileUtils.ln(@original_file.path, wf_path)
|
39
40
|
File.open(wf_path, 'r') {|f|
|
40
41
|
yield f
|