voicebase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +53 -0
- data/LICENSE.txt +22 -0
- data/README.md +88 -0
- data/Rakefile +20 -0
- data/lib/voicebase.rb +7 -0
- data/lib/voicebase/v1.rb +3 -0
- data/lib/voicebase/v1/client.rb +58 -0
- data/test/test_base.rb +6 -0
- data/test/test_setup.rb +14 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4887234109d06ee9aae59259535dbb17ad263f7c
|
4
|
+
data.tar.gz: ae769013b8a1d712358b41e249fcdd25eb9265a5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a82e2e7e1ff6d3121d11bf919e80b5a6a2fdb2ee287335eedeaa8599b0cfd30b72ed6bf99b9aeedbaf38177504b481a445c652c98a956a942ad8c36614887d7c
|
7
|
+
data.tar.gz: 6ab149b3e6694f79e5a31f51ff6c2cf244765866f73498d077b3b2bed18d2004580da0f43f3723c118516f77a819c6774d35965921f7c122422f485a4bd4c934
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
coveralls (0.8.1)
|
5
|
+
json (~> 1.8)
|
6
|
+
rest-client (>= 1.6.8, < 2)
|
7
|
+
simplecov (~> 0.10.0)
|
8
|
+
term-ansicolor (~> 1.3)
|
9
|
+
thor (~> 0.19.1)
|
10
|
+
docile (1.1.5)
|
11
|
+
domain_name (0.5.24)
|
12
|
+
unf (>= 0.0.5, < 1.0.0)
|
13
|
+
http-cookie (1.0.2)
|
14
|
+
domain_name (~> 0.5)
|
15
|
+
json (1.8.3)
|
16
|
+
metaclass (0.0.4)
|
17
|
+
mime (0.4.2)
|
18
|
+
mime-types (2.6.2)
|
19
|
+
mocha (1.1.0)
|
20
|
+
metaclass (~> 0.0.1)
|
21
|
+
netrc (0.10.3)
|
22
|
+
power_assert (0.2.4)
|
23
|
+
rake (10.4.2)
|
24
|
+
rest-client (1.8.0)
|
25
|
+
http-cookie (>= 1.0.2, < 2.0)
|
26
|
+
mime-types (>= 1.16, < 3.0)
|
27
|
+
netrc (~> 0.7)
|
28
|
+
simplecov (0.10.0)
|
29
|
+
docile (~> 1.1.0)
|
30
|
+
json (~> 1.8)
|
31
|
+
simplecov-html (~> 0.10.0)
|
32
|
+
simplecov-html (0.10.0)
|
33
|
+
term-ansicolor (1.3.0)
|
34
|
+
tins (~> 1.0)
|
35
|
+
test-unit (3.1.4)
|
36
|
+
power_assert
|
37
|
+
thor (0.19.1)
|
38
|
+
tins (1.5.2)
|
39
|
+
unf (0.1.4)
|
40
|
+
unf_ext
|
41
|
+
unf_ext (0.0.7.1)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
coveralls
|
48
|
+
mime
|
49
|
+
mime-types
|
50
|
+
mocha
|
51
|
+
rake
|
52
|
+
simplecov
|
53
|
+
test-unit
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 John Wang
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
VoiceBase Ruby SDK
|
2
|
+
==================
|
3
|
+
|
4
|
+
[![Gem Version][gem-version-svg]][gem-version-link]
|
5
|
+
[![Build Status][build-status-svg]][build-status-link]
|
6
|
+
[![Dependency Status][dependency-status-svg]][dependency-status-link]
|
7
|
+
[![Code Climate][codeclimate-status-svg]][codeclimate-status-link]
|
8
|
+
[![Scrutinizer Code Quality][scrutinizer-status-svg]][scrutinizer-status-link]
|
9
|
+
[![Downloads][downloads-svg]][downloads-link]
|
10
|
+
[![Docs][docs-rubydoc-svg]][docs-rubydoc-link]
|
11
|
+
[![License][license-svg]][license-link]
|
12
|
+
|
13
|
+
## Overview
|
14
|
+
|
15
|
+
Transcribe audio using VoiceBase.com service.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
### Via Bundler
|
20
|
+
|
21
|
+
Add 'voicebase' to Gemfile and then run `bundle`:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
$ echo "gem 'voicebase'" >> Gemfile
|
25
|
+
$ bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
### Via RubyGems
|
29
|
+
|
30
|
+
```sh
|
31
|
+
$ gem install voicebase
|
32
|
+
```
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
### From Filepath
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
voicebase = VoiceBase::V1::Client.new('myApiKey', 'myPassword')
|
40
|
+
|
41
|
+
voicebase.upload_media(
|
42
|
+
:filePath => '/path/to/myFile.mp3'
|
43
|
+
:fileContentType => 'audio/mpeg'
|
44
|
+
)
|
45
|
+
```
|
46
|
+
|
47
|
+
### From URL
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
voicebase = VoiceBase::V1::Client.new('myApiKey', 'myPassword')
|
51
|
+
|
52
|
+
voicebase.upload_media(
|
53
|
+
:mediaUrl => 'http://example.com/path/to/myFile.mp3'
|
54
|
+
)
|
55
|
+
```
|
56
|
+
|
57
|
+
## Change Log
|
58
|
+
|
59
|
+
See [CHANGELOG.md](CHANGELOG.md)
|
60
|
+
|
61
|
+
## Contributions
|
62
|
+
|
63
|
+
Any reports of problems, comments or suggestions are most welcome.
|
64
|
+
|
65
|
+
Please report these on [Github](https://github.com/grokify/voicebase-sdk-ruby)
|
66
|
+
|
67
|
+
## License
|
68
|
+
|
69
|
+
MIMEBuilder is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
|
70
|
+
|
71
|
+
MIMEBuilder © 2016 by John Wang
|
72
|
+
|
73
|
+
[gem-version-svg]: https://badge.fury.io/rb/voicebase.svg
|
74
|
+
[gem-version-link]: http://badge.fury.io/rb/voicebase
|
75
|
+
[downloads-svg]: http://ruby-gem-downloads-badge.herokuapp.com/voicebase
|
76
|
+
[downloads-link]: https://rubygems.org/gems/voicebase
|
77
|
+
[build-status-svg]: https://api.travis-ci.org/grokify/voicebase-sdk-ruby.svg?branch=master
|
78
|
+
[build-status-link]: https://travis-ci.org/grokify/voicebase-sdk-ruby
|
79
|
+
[dependency-status-svg]: https://gemnasium.com/grokify/voicebase-sdk-ruby.svg
|
80
|
+
[dependency-status-link]: https://gemnasium.com/grokify/voicebase-sdk-ruby
|
81
|
+
[codeclimate-status-svg]: https://codeclimate.com/github/grokify/voicebase-sdk-ruby/badges/gpa.svg
|
82
|
+
[codeclimate-status-link]: https://codeclimate.com/github/grokify/voicebase-sdk-ruby
|
83
|
+
[scrutinizer-status-svg]: https://scrutinizer-ci.com/g/grokify/voicebase-sdk-ruby/badges/quality-score.png?b=master
|
84
|
+
[scrutinizer-status-link]: https://scrutinizer-ci.com/g/grokify/voicebase-sdk-ruby/?branch=master
|
85
|
+
[docs-rubydoc-svg]: https://img.shields.io/badge/docs-rubydoc-blue.svg
|
86
|
+
[docs-rubydoc-link]: http://www.rubydoc.info/gems/voicebase/
|
87
|
+
[license-svg]: https://img.shields.io/badge/license-MIT-blue.svg
|
88
|
+
[license-link]: https://github.com/grokify/voicebase-sdk-ruby/blob/master/LICENSE.txt
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
desc 'Default: run unit tests.'
|
5
|
+
task :default => :test
|
6
|
+
|
7
|
+
desc 'Test the library.'
|
8
|
+
Rake::TestTask.new do |t|
|
9
|
+
t.libs << 'lib'
|
10
|
+
t.pattern = 'test/**/test_*.rb'
|
11
|
+
t.verbose = false
|
12
|
+
end
|
13
|
+
|
14
|
+
desc 'Generate YARD documentation.'
|
15
|
+
task :gendoc do
|
16
|
+
# puts 'yard doc generation disabled until JRuby build native
|
17
|
+
# extensions for redcarpet or yard removes the dependency.'
|
18
|
+
system 'yardoc'
|
19
|
+
system 'yard stats --list-undoc'
|
20
|
+
end
|
data/lib/voicebase.rb
ADDED
data/lib/voicebase/v1.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'faraday'
|
3
|
+
require 'faraday_middleware'
|
4
|
+
|
5
|
+
module VoiceBase::V1
|
6
|
+
VOICEBASE_API_VERSION = '1.1'
|
7
|
+
|
8
|
+
class Client
|
9
|
+
def initialize(api_key, password, transcript_type='machine-best')
|
10
|
+
@api_key = api_key
|
11
|
+
@password = password
|
12
|
+
@transcript_type = transcript_type
|
13
|
+
@conn_url_encoded = new_http_client :url_encoded
|
14
|
+
@conn_multipart = new_http_client :multipart
|
15
|
+
end
|
16
|
+
|
17
|
+
def new_http_client(request = :url_encoded)
|
18
|
+
conn = Faraday.new(:url => VoiceBase::VOICEBASE_API_BASE_PATH) do |faraday|
|
19
|
+
faraday.request request # multipart/form-data
|
20
|
+
faraday.response :json
|
21
|
+
faraday.response :logger # log requests to STDOUT
|
22
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
23
|
+
end
|
24
|
+
return conn
|
25
|
+
end
|
26
|
+
|
27
|
+
def upload_media(params={})
|
28
|
+
params = {
|
29
|
+
:version => VOICEBASE_API_VERSION,
|
30
|
+
:apikey => @api_key,
|
31
|
+
:password => @password,
|
32
|
+
:action => 'uploadMedia',
|
33
|
+
:title => DateTime.now.strftime('%Y-%m-%d %I:%M:%S %p'),
|
34
|
+
:transcriptType => @transcript_type,
|
35
|
+
:desc => 'file description',
|
36
|
+
:recordedDate => DateTime.now.strftime('%Y-%m-%d %I:%M:%S'),
|
37
|
+
:collection => '',
|
38
|
+
:public => false,
|
39
|
+
:sourceUrl => '',
|
40
|
+
:lang => 'en',
|
41
|
+
:imageUrl => ''
|
42
|
+
}.merge params
|
43
|
+
|
44
|
+
response = nil
|
45
|
+
|
46
|
+
if params.key?(:filePath) && params.key?(:fileContentType)
|
47
|
+
params[:file] = Faraday::UploadIO.new(params[:filePath], params[:fileContentType])
|
48
|
+
params.delete :filePath
|
49
|
+
params.delete :fileContentType
|
50
|
+
response = @conn_multipart.post '/services', params
|
51
|
+
else
|
52
|
+
response = @conn_url_encoded.post '/services', params
|
53
|
+
end
|
54
|
+
|
55
|
+
return response
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
data/test/test_base.rb
ADDED
data/test/test_setup.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require './test/test_base.rb'
|
2
|
+
|
3
|
+
class VoiceBaseTest < Test::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@vbsdk = VoiceBase::V1::Client.new(
|
6
|
+
'myApiKey',
|
7
|
+
'myPassword'
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_main
|
12
|
+
assert_equal 'VoiceBase::V1::Client', @vbsdk.class.name
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: voicebase
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Wang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday_middleware
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
- - '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
description: Helper library to transcribe audio
|
34
|
+
email: johncwang@gmail.com
|
35
|
+
executables: []
|
36
|
+
extensions: []
|
37
|
+
extra_rdoc_files: []
|
38
|
+
files:
|
39
|
+
- lib/voicebase/v1/client.rb
|
40
|
+
- lib/voicebase/v1.rb
|
41
|
+
- lib/voicebase.rb
|
42
|
+
- CHANGELOG.md
|
43
|
+
- Gemfile
|
44
|
+
- Gemfile.lock
|
45
|
+
- LICENSE.txt
|
46
|
+
- Rakefile
|
47
|
+
- README.md
|
48
|
+
- test/test_base.rb
|
49
|
+
- test/test_setup.rb
|
50
|
+
homepage: https://github.com/grokify/
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.1.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: VoiceBase is a Ruby SDK for the VoiceBase API
|
74
|
+
test_files: []
|