speechpad 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.yardopts +3 -0
- data/CONTRIBUTING.md +51 -0
- data/LICENSE.md +12 -0
- data/README.md +27 -0
- data/Rakefile +16 -0
- data/lib/speechpad.rb +23 -0
- data/lib/speechpad/client.rb +121 -0
- data/lib/speechpad/connection.rb +23 -0
- data/lib/speechpad/request.rb +40 -0
- data/lib/speechpad/version.rb +3 -0
- data/spec/helper.rb +16 -0
- data/spec/speechpad_spec.rb +89 -0
- data/speechpad.gemspec +26 -0
- metadata +129 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NzI5OGRiZDM4ODUxYWE0ZjYwMmIxNzRmZTlmYTA1ZDhkOTY2YTA3ZQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDNhNTBiMDU3ZGEwZGMxNjEwNmY4MjY0MDJmNmViZmU5NWZkNGViNA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGZkYWM1MDY3MTc5Y2MzNzUwMDdiZjFkNmQ0YzhlZDFjMGIzNzNlNzFjMWY4
|
10
|
+
ZTM3N2UzOWViMzQwZjhlZDU0MTg5N2NmM2NjOGExMTliYzhmNjYyZmVjZTFi
|
11
|
+
MmQxODQwZTJmMzlmNjIzZTQ2NTkzNzhlOGI0YjU5MTZkMzI3ZDU=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ZjFjNDBhMjFmYTI4MmQ1MjI5OWE5ZDdmNzhkMDAxMzRjYTIxYzQ0MWIxYTk1
|
14
|
+
Mzc4Njg3YTM1YWVjYzdkMTQxYTU2Njk2MGJhMzJkYTE0MGY0YjExZTM3MGJk
|
15
|
+
OWFlMDEyNDI3ZWM4ZThlNWI4ZDc2OGFmNTZkZjY3MzZkNDZkMjk=
|
data/.yardopts
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
## Contributing
|
2
|
+
In the spirit of [free software][free-sw], **everyone** is encouraged to help improve
|
3
|
+
this project.
|
4
|
+
|
5
|
+
[free-sw]: http://www.fsf.org/licensing/essays/free-sw.html
|
6
|
+
|
7
|
+
Here are some ways *you* can contribute:
|
8
|
+
|
9
|
+
* by using alpha, beta, and prerelease versions
|
10
|
+
* by reporting bugs
|
11
|
+
* by suggesting new features
|
12
|
+
* by writing or editing documentation
|
13
|
+
* by writing specifications
|
14
|
+
* by writing code (**no patch is too small**: fix typos, add comments, clean up
|
15
|
+
inconsistent whitespace)
|
16
|
+
* by refactoring code
|
17
|
+
* by fixing [issues][]
|
18
|
+
* by reviewing patches
|
19
|
+
|
20
|
+
[issues]: http://github.com/upworthy/speechpad/issues
|
21
|
+
|
22
|
+
## Submitting an Issue
|
23
|
+
We use the [GitHub issue tracker][issues] to track bugs and features. Before
|
24
|
+
submitting a bug report or feature request, check to make sure it hasn't
|
25
|
+
already been submitted. When submitting a bug report, please include a [Gist][]
|
26
|
+
that includes a stack trace and any details that may be necessary to reproduce
|
27
|
+
the bug, including your gem version, Ruby version, and operating system.
|
28
|
+
Ideally, a bug report should include a pull request with failing specs.
|
29
|
+
|
30
|
+
[gist]: https://gist.github.com/
|
31
|
+
|
32
|
+
## Submitting a Pull Request
|
33
|
+
1. [Fork the repository.][fork]
|
34
|
+
2. [Create a topic branch.][branch]
|
35
|
+
3. Add specs for your unimplemented feature or bug fix.
|
36
|
+
4. Run `bundle exec rake spec`. If your specs pass, return to step 3.
|
37
|
+
5. Implement your feature or bug fix.
|
38
|
+
6. Run `bundle exec rake spec`. If your specs fail, return to step 5.
|
39
|
+
7. Run `open coverage/index.html`. If your changes are not completely covered
|
40
|
+
by your tests, return to step 3.
|
41
|
+
8. Add documentation for your feature or bug fix.
|
42
|
+
9. Run `bundle exec rake yard`. If your changes are not 100% documented, go
|
43
|
+
back to step 8.
|
44
|
+
10. Add, commit, and push your changes.
|
45
|
+
11. [Submit a pull request.][pr]
|
46
|
+
|
47
|
+
[fork]: http://help.github.com/fork-a-repo/
|
48
|
+
[branch]: http://learn.github.com/p/branching.html
|
49
|
+
[pr]: http://help.github.com/send-pull-requests/
|
50
|
+
|
51
|
+
|
data/LICENSE.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Copyright (c) 2014, Cloud Tiger Media d.b.a. Upworthy
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
9
|
+
|
10
|
+
3. Neither the name of the Cloud Tiger Media d.b.a Upworthy nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Speechpad
|
2
|
+
A Ruby wrapper for the Speechpad API
|
3
|
+
|
4
|
+
[![Build Status](https://secure.travis-ci.org/upworthy/speechpad.png?branch=master)][travis]
|
5
|
+
[travis]: http://travis-ci.org/upworthy/speechpad
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install speechpad
|
10
|
+
|
11
|
+
## Documentation
|
12
|
+
|
13
|
+
|
14
|
+
## Usage Examples
|
15
|
+
require 'spechpad'
|
16
|
+
|
17
|
+
@client = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
18
|
+
|
19
|
+
#add_audio_url
|
20
|
+
a = @client.add_audio_url('https://www.speechpad.com/is_a.mp3')
|
21
|
+
a.response.audio_id # => 63068
|
22
|
+
|
23
|
+
## Copyright
|
24
|
+
Copyright (c) 2013 Upworthy. See [LICENSE][] for details.
|
25
|
+
|
26
|
+
[license]: https://github.com/upworthy/speechpad/blob/master/LICENSE.md
|
27
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
RSpec::Core::RakeTask.new(:spec)
|
6
|
+
|
7
|
+
task :default => :spec
|
8
|
+
task :test => :spec
|
9
|
+
|
10
|
+
require 'yard'
|
11
|
+
namespace :doc do
|
12
|
+
YARD::Rake::YardocTask.new do |task|
|
13
|
+
task.files = ['LICENSE.md', 'lib/**/*.rb']
|
14
|
+
task.options = ['--markup', 'markdown']
|
15
|
+
end
|
16
|
+
end
|
data/lib/speechpad.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'speechpad/client'
|
2
|
+
|
3
|
+
module Speechpad
|
4
|
+
class << self
|
5
|
+
# Alias for Speechpad::Client.new
|
6
|
+
#
|
7
|
+
# @return [Speechpad::Client]
|
8
|
+
def new(options={})
|
9
|
+
Speechpad::Client.new(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
# Delegate to Speechpad::Client.new
|
13
|
+
def method_missing(method, *args, &block)
|
14
|
+
return super unless new.respond_to?(method)
|
15
|
+
new.send(method, *args, &block)
|
16
|
+
end
|
17
|
+
|
18
|
+
def respond_to?(method, include_private=false)
|
19
|
+
new.respond_to?(method, include_private) || super(method, include_private)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'speechpad/connection'
|
2
|
+
require 'speechpad/request'
|
3
|
+
|
4
|
+
module Speechpad
|
5
|
+
class Client
|
6
|
+
def initialize(options={})
|
7
|
+
@access_key = options[:access_key]
|
8
|
+
@secret_key = options[:secret_key]
|
9
|
+
@speechpad_url = options[:url] || 'http://www.speechpad.com/'
|
10
|
+
end
|
11
|
+
|
12
|
+
include Speechpad::Connection
|
13
|
+
include Speechpad::Request
|
14
|
+
|
15
|
+
# Add a new audio to the user’s account from a URL, should be a file.
|
16
|
+
#
|
17
|
+
# @param url [String] A valid URL to the file to be downloaded
|
18
|
+
# @param visible_filename [String] The filename to display to user, defaults to url if blank
|
19
|
+
# @param transcribe [Boolean] 'false' - set 'true' to initiate transcription
|
20
|
+
# @param options [Hash] Optional Params
|
21
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
22
|
+
# @example Add a url of a file to be transcribed
|
23
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
24
|
+
# s.add_audio_url('https://www.speechpad.com/is_a.mp3')
|
25
|
+
def add_audio_url(url, visible_filename=url, transcribe=true, options={})
|
26
|
+
params = build_params('operation' => 'add_audio_url', 'method' => 'post', 'visible_filename' => visible_filename,
|
27
|
+
'url' => url, 'transcribe' => transcribe)
|
28
|
+
get(params, options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Add a new media to the user’s account from a URL, like Youtube.
|
32
|
+
#
|
33
|
+
# @param url [String] A valid URL to the file to be downloaded
|
34
|
+
# @param transcribe [Boolean] 'false' - set 'true' to initiate transcription
|
35
|
+
# @param options [Hash] Optional Params
|
36
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
37
|
+
# @example Add a media url to a file to be transcribed
|
38
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
39
|
+
# s.add_media_url('http://www.youtube.com/watch?v=meiU6TxysCg')
|
40
|
+
def add_media_url(url, transcribe=true, options={})
|
41
|
+
params = build_params('operation' => 'add_media_url', 'method' => 'post', 'url' => url, 'transcribe' => transcribe)
|
42
|
+
get(params, options)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Return the transcription status of one or more audio files.
|
46
|
+
#
|
47
|
+
# @param audio_id [String] The ID of the audio file
|
48
|
+
# @param options [Hash] Optional Params
|
49
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
50
|
+
# @example Get the transcription of the audio file
|
51
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
52
|
+
# s.get_transcription(1234)
|
53
|
+
def get_transcription(audio_id, options={})
|
54
|
+
params = build_params('operation' => 'get_transcription', 'method' => 'get', 'audio_id' => audio_id)
|
55
|
+
get(params, options)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Return the machine transcription status of one or more audio files.
|
59
|
+
#
|
60
|
+
# @param audio_id [String] The ID of the audio file
|
61
|
+
# @param options [Hash] Optional Params
|
62
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
63
|
+
# @example Get the machine transcription of the audio file
|
64
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
65
|
+
# s.get_machine_transcription(1234)
|
66
|
+
def get_machine_transcription(audio_id, options={})
|
67
|
+
params = build_params('operation' => 'get_machine_transcription', 'method' => 'get', 'audio_id' => audio_id)
|
68
|
+
get(params, options)
|
69
|
+
end
|
70
|
+
|
71
|
+
|
72
|
+
# Return the machine transcription status of one or more audio files.
|
73
|
+
#
|
74
|
+
# @param audio_id [String] The ID of the audio file
|
75
|
+
# @param options [Hash] Optional Params
|
76
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
77
|
+
# @example Get the machine transcription status of the audio file
|
78
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
79
|
+
# s.machine_transcription_status(1234)
|
80
|
+
def machine_transcription_status(audio_id, options={})
|
81
|
+
params = build_params('operation' => 'machine_transcription_status', 'method' => 'get', 'audio_id' => audio_id)
|
82
|
+
get(params, options)
|
83
|
+
end
|
84
|
+
|
85
|
+
# Return the transcription status of one or more audio files.
|
86
|
+
#
|
87
|
+
# @param audio_id [String] The ID of the audio file
|
88
|
+
# @param options [Hash] Optional Params
|
89
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
90
|
+
# @example Get the transcription status of the audio file
|
91
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
92
|
+
# s.transcription_status(1234)
|
93
|
+
def transcription_status(audio_id, options={})
|
94
|
+
params = build_params('operation' => 'transcription_status', 'method' => 'get', 'audio_id' => audio_id)
|
95
|
+
get(params, options)
|
96
|
+
end
|
97
|
+
|
98
|
+
# A test call for the Speechpad API (only works on dev).
|
99
|
+
#
|
100
|
+
# @param options [Hash] Optional Params
|
101
|
+
# @return [Mash] Mashify body with ERROR_STRING and Response
|
102
|
+
# @example Get the transcription status of the audio file
|
103
|
+
# s = Speechpad::Client.new({access_key: "abc123", secret_key: "xyz456"})
|
104
|
+
# s.test
|
105
|
+
def test(options={})
|
106
|
+
params = build_params('operation' => 'test', 'value' => '123', 'method' => 'get')
|
107
|
+
get(params, options)
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
def build_params(params)
|
113
|
+
params['service_name'] = 'account'
|
114
|
+
params['service_version'] = '1.0.0'
|
115
|
+
params['access_key'] = @access_key
|
116
|
+
params['format'] = 'json'
|
117
|
+
params
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
121
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module Speechpad
|
5
|
+
# @private
|
6
|
+
module Connection
|
7
|
+
private
|
8
|
+
|
9
|
+
def connection(options={})
|
10
|
+
connection = Faraday.new @speechpad_url do |conn|
|
11
|
+
# Uncomment if want to log to stdout
|
12
|
+
#conn.response :logger
|
13
|
+
|
14
|
+
conn.request :url_encoded
|
15
|
+
conn.response :mashify
|
16
|
+
conn.response :json, :content_type => /\bjson$/
|
17
|
+
|
18
|
+
conn.adapter Faraday.default_adapter
|
19
|
+
end
|
20
|
+
connection
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'base64'
|
2
|
+
require 'openssl'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
module Speechpad
|
6
|
+
module Request
|
7
|
+
|
8
|
+
def get(params, options={})
|
9
|
+
params = generate_signature(params)
|
10
|
+
request(:get, params, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def post(params, options={})
|
14
|
+
params = generate_signature(params)
|
15
|
+
request(:post, params, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# POST the Params to the Speechpad end point.
|
21
|
+
#
|
22
|
+
# @param body [String] The formatted XML of the API call make sure to call builder.to_xml.
|
23
|
+
def request(method, params, options)
|
24
|
+
response = connection.send(method) do |request|
|
25
|
+
request.url '/services', params
|
26
|
+
end
|
27
|
+
response.body
|
28
|
+
end
|
29
|
+
|
30
|
+
def generate_signature(params)
|
31
|
+
params["timestamp"] = Time.now.utc.strftime('%Y-%m-%dT%H:%M:%SZ')
|
32
|
+
|
33
|
+
s = params.keys.sort.map{|key| params[key]}.join('')
|
34
|
+
params["signature"] = Base64.encode64(OpenSSL::HMAC.digest('sha1',@secret_key, s))[0,28]
|
35
|
+
|
36
|
+
params
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/spec/helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
unless ENV['CI']
|
2
|
+
require 'simplecov'
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter 'spec'
|
5
|
+
end
|
6
|
+
end
|
7
|
+
require 'speechpad'
|
8
|
+
require 'rspec'
|
9
|
+
require 'timecop'
|
10
|
+
require 'webmock/rspec'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
config.before(:all) do
|
14
|
+
Timecop.freeze(Time.local(2014))
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Speechpad do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Speechpad::Client.new({access_key: 'abc123', secret_key: 'xyz456', url: 'http://dev.speechpad.com'})
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".new" do
|
10
|
+
it "should be a new Speechpad::Client" do
|
11
|
+
Speechpad.new.should be_a Speechpad::Client
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ".respond_to?" do
|
16
|
+
it "should be true if method exists" do
|
17
|
+
Speechpad.respond_to?(:new, true).should be_true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe ".test" do
|
22
|
+
it "should make a test call to the Speechpad API" do
|
23
|
+
|
24
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&format=json&method=get&operation=test&service_name=account&service_version=1.0.0&signature=MP6ZzbYANYB7vuJnUIg40Z2yPz4=×tamp=2014-01-01T08:00:00Z&value=123").
|
25
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS","response":{"value":"123"}}', :headers => {'Content-Type' => 'application/json'})
|
26
|
+
|
27
|
+
@client.test.response.value.should eql "123"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe ".add_audio_url" do
|
32
|
+
it "should be a success when passing a url with a file to transcribe" do
|
33
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&format=json&method=post&operation=add_audio_url&service_name=account&service_version=1.0.0&signature=0in1rEuhI%2BHdXZqQg7dAGlV3AEE=×tamp=2014-01-01T08:00:00Z&transcribe=true&url=https://www.speechpad.com/is_a.mp3&visible_filename=https://www.speechpad.com/is_a.mp3").
|
34
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS", "response":{"audio_id": 63068}}' , :headers => {'Content-Type' => 'application/json'})
|
35
|
+
|
36
|
+
test = @client.add_audio_url('https://www.speechpad.com/is_a.mp3')
|
37
|
+
test.response.audio_id.should eql 63068
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe ".add_media_url" do
|
42
|
+
it "should be a success when passing a url to transcribe" do
|
43
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&format=json&method=post&operation=add_media_url&service_name=account&service_version=1.0.0&signature=YOWA%2BAut3xvLaKhBe2sc5vr%2BZ1o=×tamp=2014-01-01T08:00:00Z&transcribe=true&url=http://www.youtube.com/watch?v=meiU6TxysCg").
|
44
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS", "response":{"audio_id": 63068}}' , :headers => {'Content-Type' => 'application/json'})
|
45
|
+
|
46
|
+
test = @client.add_media_url('http://www.youtube.com/watch?v=meiU6TxysCg')
|
47
|
+
test.response.audio_id.should eql 63068
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe ".get_transcription" do
|
52
|
+
it "should get the transcription of the audo file and return it" do
|
53
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&audio_id=1234&format=json&method=get&operation=get_transcription&service_name=account&service_version=1.0.0&signature=KjqOK1mHDkyMVi%2B%2Bj%2BnpwZEdTCw=×tamp=2014-01-01T08:00:00Z").
|
54
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS","response":"Hello!"}' , :headers => {'Content-Type' => 'application/json'})
|
55
|
+
test = @client.get_transcription(1234)
|
56
|
+
test.response.should eql "Hello!"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe ".get_machine_transcription" do
|
61
|
+
it "should get the machine transcription of the audo file and return it" do
|
62
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&audio_id=1234&format=json&method=get&operation=get_machine_transcription&service_name=account&service_version=1.0.0&signature=wBZvG0znUqF1YvvJXEbQzF%2Buq1k=×tamp=2014-01-01T08:00:00Z").
|
63
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS","response":"Hello!"}' , :headers => {'Content-Type' => 'application/json'})
|
64
|
+
|
65
|
+
test = @client.get_machine_transcription(1234)
|
66
|
+
test.response.should eql "Hello!"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe ".machine_transcription_status" do
|
71
|
+
it "should get the status of the machine trascript with the given id" do
|
72
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&audio_id=1234&format=json&method=get&operation=machine_transcription_status&service_name=account&service_version=1.0.0&signature=k4tkFqwsZYrHpVDl0JYCzs6LtLE=×tamp=2014-01-01T08:00:00Z").
|
73
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS","response":{"1234":"done"}}' , :headers => {'Content-Type' => 'application/json'})
|
74
|
+
test = @client.machine_transcription_status('1234')
|
75
|
+
test.response['1234'].should eql 'done'
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe ".transcription_status" do
|
80
|
+
it "should get the status of the transcription with the given id" do
|
81
|
+
stub_request(:get, "http://dev.speechpad.com/services?access_key=abc123&audio_id=1234&format=json&method=get&operation=transcription_status&service_name=account&service_version=1.0.0&signature=YOHVemU8vLwSMsuinuOGifgLfsg=×tamp=2014-01-01T08:00:00Z").
|
82
|
+
to_return(:status => 200, :body => '{"error_string":"SUCCESS","response":{"1234":"done"}}' , :headers => {'Content-Type' => 'application/json'})
|
83
|
+
test = @client.transcription_status('1234')
|
84
|
+
test.response['1234'].should eql 'done'
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
|
89
|
+
end
|
data/speechpad.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'speechpad/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.add_dependency 'faraday', '~> 0.8.8'
|
8
|
+
spec.add_dependency 'faraday_middleware', '~> 0.9'
|
9
|
+
spec.add_dependency 'hashie', '~> 2.0'
|
10
|
+
spec.add_dependency 'json', '~> 1.8'
|
11
|
+
spec.add_development_dependency 'bundler', '~> 1.0'
|
12
|
+
spec.author = 'Upworthy'
|
13
|
+
spec.description = %q{A Ruby library for interacting with the Speechpad API}
|
14
|
+
spec.email = 'webmaster@upworthy.com'
|
15
|
+
spec.files = %w(.yardopts CONTRIBUTING.md LICENSE.md README.md Rakefile speechpad.gemspec)
|
16
|
+
spec.files += Dir.glob('lib/**/*.rb')
|
17
|
+
spec.files += Dir.glob('spec/**/*')
|
18
|
+
spec.homepage = 'https://github.com/upworthy/speechpad'
|
19
|
+
spec.licenses = ['BSD-3-Clause']
|
20
|
+
spec.name = 'speechpad'
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
spec.required_rubygems_version = '>= 1.3.5'
|
23
|
+
spec.summary = spec.description
|
24
|
+
spec.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
25
|
+
spec.version = Speechpad::VERSION
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: speechpad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Upworthy
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.8
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.8
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.9'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.0'
|
83
|
+
description: A Ruby library for interacting with the Speechpad API
|
84
|
+
email: webmaster@upworthy.com
|
85
|
+
executables: []
|
86
|
+
extensions: []
|
87
|
+
extra_rdoc_files: []
|
88
|
+
files:
|
89
|
+
- .yardopts
|
90
|
+
- CONTRIBUTING.md
|
91
|
+
- LICENSE.md
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- speechpad.gemspec
|
95
|
+
- lib/speechpad/client.rb
|
96
|
+
- lib/speechpad/connection.rb
|
97
|
+
- lib/speechpad/request.rb
|
98
|
+
- lib/speechpad/version.rb
|
99
|
+
- lib/speechpad.rb
|
100
|
+
- spec/helper.rb
|
101
|
+
- spec/speechpad_spec.rb
|
102
|
+
homepage: https://github.com/upworthy/speechpad
|
103
|
+
licenses:
|
104
|
+
- BSD-3-Clause
|
105
|
+
metadata: {}
|
106
|
+
post_install_message:
|
107
|
+
rdoc_options: []
|
108
|
+
require_paths:
|
109
|
+
- lib
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ! '>='
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
|
+
requirements:
|
117
|
+
- - ! '>='
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
version: 1.3.5
|
120
|
+
requirements: []
|
121
|
+
rubyforge_project:
|
122
|
+
rubygems_version: 2.1.10
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: A Ruby library for interacting with the Speechpad API
|
126
|
+
test_files:
|
127
|
+
- spec/helper.rb
|
128
|
+
- spec/speechpad_spec.rb
|
129
|
+
has_rdoc:
|