google_speech 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b1bce8c353b7d08b07ee1a1347467798892e5901
4
- data.tar.gz: 485519ee0d04a58bccb17c84aefdc8aa43898211
3
+ metadata.gz: 1e8c0b050e64d5ccc7521777e0b320f5544eff3b
4
+ data.tar.gz: 7389a2c17862a3a3e31359b721fa9d2eeb8d3c3b
5
5
  SHA512:
6
- metadata.gz: 852dd2b57c980bd31881a2ea9f5c54d6ea5599dede6068f15d31593d5b377cf8c18b074013febdd463c3a7c8bb39e93939d17ebcea499271bcf443553ef22a98
7
- data.tar.gz: 2cce04f52058ee5c5af6ba6c7906b4f51d0f693be3350c85a23d6e2ea07e331e0ca912875fed7f41c7d799f991a31ac295e7da7c48045eeea484bbba0b4fbf71
6
+ metadata.gz: 5d33ab4b317a1ef3acaa48e9d05c9e47248a8e5b0fc19de80a32729f0b7a37de0fe0d595ea56d63fefe14a78a41ac7e0fe261e53e54f34b2bc6ccf374e7c869c
7
+ data.tar.gz: d2c37ebff2fb005d3fa8a69c860104977481f17b545be69ced5fb3c576d4a2940acf8b0ef074de8f715f2a8477dfd0a2c025e48ddf7be15dd286dade706b19ae
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ before_install:
5
+ - sudo apt-get update -qq
6
+ - sudo apt-get install libsox-fmt-all -y
7
+ - sudo apt-get install sox -y
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # GoogleSpeech
2
2
 
3
+ [![Build Status](https://travis-ci.org/PRX/google_speech.svg)](https://travis-ci.org/PRX/google_speech)
4
+
3
5
  This is a gem to call the google speech api.
4
6
 
5
7
  The gem expects pcm wav audio.
@@ -9,6 +9,7 @@ module GoogleSpeech
9
9
  attr_accessor :original_file, :options, :results
10
10
 
11
11
  DEFAULT_OPTIONS = {
12
+ :key => 'AIzaSyCnl6MRydhw_5fLXIdASxkLJzcJh5iX0M4',
12
13
  :language => 'en-US',
13
14
  :chunk_duration => 5,
14
15
  :overlap => 0.5,
@@ -54,8 +55,8 @@ module GoogleSpeech
54
55
  end
55
56
 
56
57
  def result_from_transcript(transcript)
57
- hyp = transcript['hypotheses'].first
58
- hyp ? { :text => hyp['utterance'], :confidence => hyp['confidence'] } : nil
58
+ alt = transcript['result'].first['alternative'].first rescue nil
59
+ alt ? { :text => alt['transcript'], :confidence => (alt['confidence'] || '0.9') } : nil
59
60
  end
60
61
 
61
62
  def pfilter
@@ -64,8 +65,8 @@ module GoogleSpeech
64
65
 
65
66
  def transcribe_data(data)
66
67
  params = {
67
- :path => "/speech-api/v1/recognize",
68
- :query => "xjerr=1&client=chromium&lang=#{options[:language]}&maxresults=#{options[:max_results].to_i}&pfilter=#{pfilter}",
68
+ :path => "/speech-api/v2/recognize",
69
+ :query => "output=json&client=chromium&lang=#{options[:language]}&key=#{options[:key]}",
69
70
  :body => data,
70
71
  :method => 'POST',
71
72
  :headers => {
@@ -85,7 +86,7 @@ module GoogleSpeech
85
86
  connection = Excon.new(url)
86
87
  response = connection.request(params)
87
88
  # puts "response: #{response.inspect}\n\n"
88
- # puts "response.body: #{response.body}\n\n"
89
+ # puts "response.body:\nSTART\n#{response.body}\nEND\n#{response.body.class.name}"
89
90
  if response.status.to_s.start_with?('2')
90
91
  result = []
91
92
  if (response.body && response.body.size > 0)
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module GoogleSpeech
4
- VERSION = "0.2.2"
4
+ VERSION = "0.3.0"
5
5
  end
data/spec/spec_helper.rb CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  gem 'minitest'
4
4
 
5
- require 'minitest/spec'
6
5
  require 'minitest/autorun'
6
+ require 'minitest/spec'
7
7
 
8
8
  $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
9
9
  require 'google_speech'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: google_speech
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kuklewicz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-18 00:00:00.000000000 Z
11
+ date: 2014-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - .gitignore
64
+ - .travis.yml
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md