voicebase 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -1
- data/README.md +24 -6
- data/Rakefile +1 -1
- data/lib/voicebase.rb +2 -2
- data/lib/voicebase/v1.rb +5 -3
- data/lib/voicebase/v1/client.rb +30 -28
- data/test/test_setup.rb +2 -0
- data/voicebase.gemspec +19 -0
- metadata +14 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd58117befe74a4921b5224da4d60b4ce1b03186
|
4
|
+
data.tar.gz: 9939f9f183c1ccb1eeba9901ca91890ebe07ca47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8668f2b6816639bbf9e59a33e32e6e75e251110b73f29e15aba07fd8178005db307211df8c48e0501184dc87b958df3d22e82bf308c9f423221e6f94597b400d
|
7
|
+
data.tar.gz: 81423b784a94bf38b72b03caa36b518e692e4312bb5f2f6a7a71494098f0b8c4a2fdca00978704111827525fd90581ade91295699b9fdc7fd37500d3200b5b39
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -12,13 +12,13 @@ VoiceBase Ruby SDK
|
|
12
12
|
|
13
13
|
## Overview
|
14
14
|
|
15
|
-
|
15
|
+
Ruby SDK for VoiceBase.com audio transcription service.
|
16
16
|
|
17
17
|
## Installation
|
18
18
|
|
19
19
|
### Via Bundler
|
20
20
|
|
21
|
-
Add
|
21
|
+
Add `voicebase` to Gemfile and then run `bundle`:
|
22
22
|
|
23
23
|
```sh
|
24
24
|
$ echo "gem 'voicebase'" >> Gemfile
|
@@ -33,18 +33,30 @@ $ gem install voicebase
|
|
33
33
|
|
34
34
|
## Usage
|
35
35
|
|
36
|
-
###
|
36
|
+
### Upload Media
|
37
|
+
|
38
|
+
The `upload_media` method will accept a hash of parameters to send to the VoiceBase API. All supported parameters can be passed in.
|
39
|
+
|
40
|
+
#### From Filepath
|
41
|
+
|
42
|
+
Using SDK helper the `:filePath` and `:fileContentType` parameters will be auto-converted to a `:file` parameter supported by the VoiceBase API. It is also possible to directly include a `:file` parameter using `Faraday::UploadIO`.
|
37
43
|
|
38
44
|
```ruby
|
39
45
|
voicebase = VoiceBase::V1::Client.new('myApiKey', 'myPassword')
|
40
46
|
|
47
|
+
# Using SDK Helpers
|
41
48
|
voicebase.upload_media(
|
42
49
|
:filePath => '/path/to/myFile.mp3'
|
43
50
|
:fileContentType => 'audio/mpeg'
|
44
51
|
)
|
52
|
+
|
53
|
+
# Using Faraday::UploadIO directly
|
54
|
+
voicebase.upload_media(
|
55
|
+
:file => Faraday::UploadIO.new('/path/to/myFile.mp3', 'audio/mpeg')
|
56
|
+
)
|
45
57
|
```
|
46
58
|
|
47
|
-
|
59
|
+
#### From URL
|
48
60
|
|
49
61
|
```ruby
|
50
62
|
voicebase = VoiceBase::V1::Client.new('myApiKey', 'myPassword')
|
@@ -58,6 +70,12 @@ voicebase.upload_media(
|
|
58
70
|
|
59
71
|
See [CHANGELOG.md](CHANGELOG.md)
|
60
72
|
|
73
|
+
## Links
|
74
|
+
|
75
|
+
Project Repo
|
76
|
+
|
77
|
+
* https://github.com/grokify/voicebase-sdk-ruby
|
78
|
+
|
61
79
|
## Contributions
|
62
80
|
|
63
81
|
Any reports of problems, comments or suggestions are most welcome.
|
@@ -66,9 +84,9 @@ Please report these on [Github](https://github.com/grokify/voicebase-sdk-ruby)
|
|
66
84
|
|
67
85
|
## License
|
68
86
|
|
69
|
-
|
87
|
+
VoiceBase Ruby SDK is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
|
70
88
|
|
71
|
-
|
89
|
+
VoiceBase Ruby SDK © 2016 by John Wang
|
72
90
|
|
73
91
|
[gem-version-svg]: https://badge.fury.io/rb/voicebase.svg
|
74
92
|
[gem-version-link]: http://badge.fury.io/rb/voicebase
|
data/Rakefile
CHANGED
data/lib/voicebase.rb
CHANGED
data/lib/voicebase/v1.rb
CHANGED
data/lib/voicebase/v1/client.rb
CHANGED
@@ -5,8 +5,11 @@ require 'faraday_middleware'
|
|
5
5
|
module VoiceBase::V1
|
6
6
|
VOICEBASE_API_VERSION = '1.1'
|
7
7
|
|
8
|
+
attr_accessor :conn_url_encoded
|
9
|
+
attr_accessor :conn_multipart
|
10
|
+
|
8
11
|
class Client
|
9
|
-
def initialize(api_key, password, transcript_type='machine-best')
|
12
|
+
def initialize(api_key, password, transcript_type = 'machine-best')
|
10
13
|
@api_key = api_key
|
11
14
|
@password = password
|
12
15
|
@transcript_type = transcript_type
|
@@ -15,44 +18,43 @@ module VoiceBase::V1
|
|
15
18
|
end
|
16
19
|
|
17
20
|
def new_http_client(request = :url_encoded)
|
18
|
-
|
19
|
-
|
21
|
+
Faraday.new(url: VoiceBase::VOICEBASE_API_BASE_PATH) \
|
22
|
+
do |faraday|
|
23
|
+
faraday.request request
|
20
24
|
faraday.response :json
|
21
|
-
faraday.response :logger
|
22
|
-
faraday.adapter
|
25
|
+
faraday.response :logger # log requests to STDOUT
|
26
|
+
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
23
27
|
end
|
24
|
-
return conn
|
25
28
|
end
|
26
29
|
|
27
|
-
def upload_media(params={})
|
30
|
+
def upload_media(params = {})
|
28
31
|
params = {
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
32
|
+
version: VOICEBASE_API_VERSION,
|
33
|
+
apikey: @api_key,
|
34
|
+
password: @password,
|
35
|
+
action: 'uploadMedia',
|
36
|
+
title: DateTime.now.strftime('%Y-%m-%d %I:%M:%S %p'),
|
37
|
+
transcriptType: @transcript_type,
|
38
|
+
desc: 'file description',
|
39
|
+
recordedDate: DateTime.now.strftime('%Y-%m-%d %I:%M:%S'),
|
40
|
+
collection: '',
|
41
|
+
public: false,
|
42
|
+
sourceUrl: '',
|
43
|
+
lang: 'en',
|
44
|
+
imageUrl: ''
|
42
45
|
}.merge params
|
43
46
|
|
44
|
-
response = nil
|
45
|
-
|
46
47
|
if params.key?(:filePath) && params.key?(:fileContentType)
|
47
|
-
params[:file] = Faraday::UploadIO.new(
|
48
|
+
params[:file] = Faraday::UploadIO.new(
|
49
|
+
params[:filePath],
|
50
|
+
params[:fileContentType]
|
51
|
+
)
|
48
52
|
params.delete :filePath
|
49
53
|
params.delete :fileContentType
|
50
|
-
|
54
|
+
return @conn_multipart.post '/services', params
|
51
55
|
else
|
52
|
-
|
56
|
+
return @conn_url_encoded.post '/services', params
|
53
57
|
end
|
54
|
-
|
55
|
-
return response
|
56
58
|
end
|
57
59
|
end
|
58
|
-
end
|
60
|
+
end
|
data/test/test_setup.rb
CHANGED
data/voicebase.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
lib = 'voicebase'
|
2
|
+
lib_file = File.expand_path("../lib/#{lib}.rb", __FILE__)
|
3
|
+
File.read(lib_file) =~ /\bVERSION\s*=\s*["'](.+?)["']/
|
4
|
+
version = $1
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = lib
|
8
|
+
s.version = version
|
9
|
+
s.date = '2016-01-30'
|
10
|
+
s.summary = 'VoiceBase is a Ruby SDK for the VoiceBase API'
|
11
|
+
s.description = 'Helper library to transcribe audio'
|
12
|
+
s.authors = ['John Wang']
|
13
|
+
s.email = 'johncwang@gmail.com'
|
14
|
+
s.homepage = 'https://github.com/grokify/'
|
15
|
+
s.licenses = ['MIT']
|
16
|
+
s.files = Dir['lib/**/**/*'] + Dir['[A-Z]*'] + Dir['test/**/*']
|
17
|
+
# s.files.reject! { |fn| fn.include? "CVS" }
|
18
|
+
s.add_dependency 'faraday_middleware', '~> 0', '>= 0'
|
19
|
+
end
|
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voicebase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday_middleware
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
-
- -
|
20
|
+
- - ">="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - ~>
|
27
|
+
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
- -
|
30
|
+
- - ">="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '0'
|
33
33
|
description: Helper library to transcribe audio
|
@@ -36,17 +36,18 @@ executables: []
|
|
36
36
|
extensions: []
|
37
37
|
extra_rdoc_files: []
|
38
38
|
files:
|
39
|
-
- lib/voicebase/v1/client.rb
|
40
|
-
- lib/voicebase/v1.rb
|
41
|
-
- lib/voicebase.rb
|
42
39
|
- CHANGELOG.md
|
43
40
|
- Gemfile
|
44
41
|
- Gemfile.lock
|
45
42
|
- LICENSE.txt
|
46
|
-
- Rakefile
|
47
43
|
- README.md
|
44
|
+
- Rakefile
|
45
|
+
- lib/voicebase.rb
|
46
|
+
- lib/voicebase/v1.rb
|
47
|
+
- lib/voicebase/v1/client.rb
|
48
48
|
- test/test_base.rb
|
49
49
|
- test/test_setup.rb
|
50
|
+
- voicebase.gemspec
|
50
51
|
homepage: https://github.com/grokify/
|
51
52
|
licenses:
|
52
53
|
- MIT
|
@@ -57,17 +58,17 @@ require_paths:
|
|
57
58
|
- lib
|
58
59
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
|
-
- -
|
61
|
+
- - ">="
|
61
62
|
- !ruby/object:Gem::Version
|
62
63
|
version: '0'
|
63
64
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
65
|
requirements:
|
65
|
-
- -
|
66
|
+
- - ">="
|
66
67
|
- !ruby/object:Gem::Version
|
67
68
|
version: '0'
|
68
69
|
requirements: []
|
69
70
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
71
|
+
rubygems_version: 2.4.8
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
74
|
summary: VoiceBase is a Ruby SDK for the VoiceBase API
|