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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4887234109d06ee9aae59259535dbb17ad263f7c
4
- data.tar.gz: ae769013b8a1d712358b41e249fcdd25eb9265a5
3
+ metadata.gz: bd58117befe74a4921b5224da4d60b4ce1b03186
4
+ data.tar.gz: 9939f9f183c1ccb1eeba9901ca91890ebe07ca47
5
5
  SHA512:
6
- metadata.gz: a82e2e7e1ff6d3121d11bf919e80b5a6a2fdb2ee287335eedeaa8599b0cfd30b72ed6bf99b9aeedbaf38177504b481a445c652c98a956a942ad8c36614887d7c
7
- data.tar.gz: 6ab149b3e6694f79e5a31f51ff6c2cf244765866f73498d077b3b2bed18d2004580da0f43f3723c118516f77a819c6774d35965921f7c122422f485a4bd4c934
6
+ metadata.gz: 8668f2b6816639bbf9e59a33e32e6e75e251110b73f29e15aba07fd8178005db307211df8c48e0501184dc87b958df3d22e82bf308c9f423221e6f94597b400d
7
+ data.tar.gz: 81423b784a94bf38b72b03caa36b518e692e4312bb5f2f6a7a71494098f0b8c4a2fdca00978704111827525fd90581ade91295699b9fdc7fd37500d3200b5b39
@@ -1,4 +1,6 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
  - **2016-01-25**: 0.0.1
4
- - Initial release
4
+ - Initial release
5
+ - Upload media from file system
6
+ - Upload media from URL
data/README.md CHANGED
@@ -12,13 +12,13 @@ VoiceBase Ruby SDK
12
12
 
13
13
  ## Overview
14
14
 
15
- Transcribe audio using VoiceBase.com service.
15
+ Ruby SDK for VoiceBase.com audio transcription service.
16
16
 
17
17
  ## Installation
18
18
 
19
19
  ### Via Bundler
20
20
 
21
- Add 'voicebase' to Gemfile and then run `bundle`:
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
- ### From Filepath
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
- ### From URL
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
- MIMEBuilder is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
87
+ VoiceBase Ruby SDK is available under an MIT-style license. See [LICENSE.txt](LICENSE.txt) for details.
70
88
 
71
- MIMEBuilder © 2016 by John Wang
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
@@ -2,7 +2,7 @@ require 'rake'
2
2
  require 'rake/testtask'
3
3
 
4
4
  desc 'Default: run unit tests.'
5
- task :default => :test
5
+ task default: :test
6
6
 
7
7
  desc 'Test the library.'
8
8
  Rake::TestTask.new do |t|
@@ -1,7 +1,7 @@
1
1
  module VoiceBase
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
 
4
4
  VOICEBASE_API_BASE_PATH = 'https://api.voicebase.com/services'
5
5
 
6
6
  autoload :V1, 'voicebase/v1'
7
- end
7
+ end
@@ -1,3 +1,5 @@
1
- module VoiceBase::V1
2
- autoload :Client, 'voicebase/v1/client'
3
- end
1
+ module VoiceBase
2
+ module V1
3
+ autoload :Client, 'voicebase/v1/client'
4
+ end
5
+ end
@@ -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
- conn = Faraday.new(:url => VoiceBase::VOICEBASE_API_BASE_PATH) do |faraday|
19
- faraday.request request # multipart/form-data
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 # log requests to STDOUT
22
- faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
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
- :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 => ''
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(params[:filePath], params[:fileContentType])
48
+ params[:file] = Faraday::UploadIO.new(
49
+ params[:filePath],
50
+ params[:fileContentType]
51
+ )
48
52
  params.delete :filePath
49
53
  params.delete :fileContentType
50
- response = @conn_multipart.post '/services', params
54
+ return @conn_multipart.post '/services', params
51
55
  else
52
- response = @conn_url_encoded.post '/services', params
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
@@ -10,5 +10,7 @@ class VoiceBaseTest < Test::Unit::TestCase
10
10
 
11
11
  def test_main
12
12
  assert_equal 'VoiceBase::V1::Client', @vbsdk.class.name
13
+
14
+ assert_equal 'Faraday::Connection', @vbsdk.new_http_client.class.name
13
15
  end
14
16
  end
@@ -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.1
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-25 00:00:00.000000000 Z
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.1.5
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