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
- M2I5ODY4NzA3Mzg1OTcyZjJlYWJlNjc2ZjdhMDc4ZjcyYzcxOTkwYQ==
4
+ ZDY1ODIwZjVkZWExN2NkYzdlYTBkMGMzMzdkMzQ2N2U0M2Q0OTJjYg==
5
5
  data.tar.gz: !binary |-
6
- YTkyYWY0NTExNjRmZDZjY2VmYjdjYTZjMGZlZDJjY2QyMzEyOWRjMw==
6
+ OGRjOTQ2NGFkNDMzZTJhMGEwOTBkOWMxMzE5ODVjZDMyZDBkZDM3Mw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NDQ0NThhNzhkMjg3YjExNTk5ZmRkNmRjMDc1YTMwMjcxYTg0N2FlZWE5YjVi
10
- OWNlN2U4ZWM1NWJmN2QyZTgwMTJiMDgzYmQwZTlmMDBhMmNlMDdlMmZiZTFj
11
- NmE3OTc1MThjZmVkNzEyYmUxYTg1NTQ5OTgyN2UyMzI5Mzg4MTA=
9
+ MzMxOGYzMTcyMDcwYmNhMTI1OTI4ZWZmZDA0NjlmYmRjNWEzMjBkNjkzYzM5
10
+ YmMyZjdjZDEyZmIyZDJjNGE1ZmZmODE5ZDBlYWE4ZjQzZWZmMDYyNzY2ZDc3
11
+ ODQwMTMyZDY3ZGExZGM0ZmY1ZDZmZmNkZjg1ZjdhMWE1ODQ5ZWQ=
12
12
  data.tar.gz: !binary |-
13
- YjU5ODViY2QwNjJjZjVlMGQzNmI4ZDJmYmUxMmEyNTY1NDViYWU3MjdkZDlh
14
- ZjM4M2NkZDk4NDNiZTZlOTc5YTBjMmY0OGYyOTU3Mzk3Y2VhOGRhMGYwNWY4
15
- ODVjOTI0ZGE5OGRhM2Q4ODQ3ODU0NDhmMzI3ZDkwMTVlNjI4ZDI=
13
+ YTc2ZWVkNTAwNDdiNTQ3OWFmYzY2MGQxYzliYmMzZDVmMjg1MGJjZmZiNGE3
14
+ NTBiY2RjODM4YzlmZWZjYjRlMWZlM2EzNDE1MWVkZDUxYjRhMmI5Zjg0MjNk
15
+ MzVhYzhkZDI2ZjJmZjQ3MjU5NWVlYjI3OWU0YmRjMjRiM2NiZDU=
@@ -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.to_i
13
- @start_time = start_time.to_i
14
- @duration = [duration.to_i, (@original_duration - @start_time)].min
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.to_i
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).to_i
13
+ @original_duration = GoogleSpeech::Utility.audio_file_duration(@original_file.path)
14
14
  end
15
15
 
16
16
  # return temp file for each chunk
@@ -11,7 +11,7 @@ module GoogleSpeech
11
11
  DEFAULT_OPTIONS = {
12
12
  :language => 'en-US',
13
13
  :chunk_duration => 5,
14
- :overlap => 1,
14
+ :overlap => 0.5,
15
15
  :max_results => 1,
16
16
  :request_pause => 1,
17
17
  :profanity_filter => true
@@ -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.to_i} #{length.to_i} compand .5,2 -80,-80,-75,-50,-30,-15,0,0 norm -0.1"
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.to_i} #{length.to_i} rate 16k"
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
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module GoogleSpeech
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_speech
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kuklewicz