voice_id 0.1.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.
@@ -0,0 +1,4 @@
1
+ require "rspec"
2
+ require "mimic"
3
+ require_relative "../lib/voice_id.rb"
4
+ require_relative "mock_server.rb"
@@ -0,0 +1,80 @@
1
+ require_relative "spec_helper"
2
+
3
+ describe VoiceId::Verification do
4
+
5
+ before :each do
6
+ @verification = VoiceId::Verification.new("some_api_key")
7
+ @verification.api_base_url = "http://localhost:11988"
8
+ end
9
+
10
+ describe "#create_profile" do
11
+ it "should be able to create a new profile and return the details" do
12
+ expect(@verification.create_profile).to eql(@new_verification_profile)
13
+ end
14
+ end
15
+
16
+ describe "#delete_profile" do
17
+ it "should delete a profile and return true" do
18
+ profileId = "12345678"
19
+ expect(@verification.delete_profile(profileId)).to eql(true)
20
+ end
21
+ end
22
+
23
+ describe "#get_all_profiles" do
24
+ it "should return an array of all profiles" do
25
+ expect(@verification.get_all_profiles).to eql(@verification_profiles)
26
+ end
27
+ end
28
+
29
+ describe "#get_profile" do
30
+ it "should return a profile hash" do
31
+ profileId = "987654321"
32
+ expect(@verification.get_profile(profileId)).to eql(@verification_profile)
33
+ end
34
+ end
35
+
36
+ describe "#create_enrollment" do
37
+ it "should create a new enrollment for a profile and return an operation url" do
38
+ data = { :form => { :file => "cool.wav" } }
39
+ profileId = "0991883883"
40
+ allow_any_instance_of(VoiceId::RequestHelpers).to receive(:create_body_for_enrollment).and_return(data)
41
+ expect(@verification.create_enrollment(profileId, '/path/to/some/audio_file.wav')).to eql(@verification_enrollment_response)
42
+ end
43
+ end
44
+
45
+ describe "#reset_all_enrollments_for_profile" do
46
+ it "should return true if all enrollments for a profile was deleted" do
47
+ profileId = "0991883883"
48
+ expect(@verification.reset_all_enrollments_for_profile(profileId)).to eql(true)
49
+ end
50
+ end
51
+
52
+ describe "#get_operation_id" do
53
+ it "returns an operation id" do
54
+ operation_url = "https://api.projectoxford.ai/spid/v1.0/operations/995a8745-0098-4c12-9889-bad14859y7a4"
55
+ expect(@verification.get_operation_id(operation_url)).to eql("995a8745-0098-4c12-9889-bad14859y7a4")
56
+ end
57
+ end
58
+
59
+ describe "#list_all_verification_phrases" do
60
+ it "lists all acceptable phrases available" do
61
+ expect(@verification.list_all_verification_phrases).to eql(@all_verification_phrases)
62
+ end
63
+ end
64
+
65
+ describe "#verify_speaker" do
66
+ it "verifies speaker against known phrase" do
67
+ data = { :form => { :file => "cool.wav" } }
68
+ profileId = "0991883883"
69
+ allow_any_instance_of(VoiceId::RequestHelpers).to receive(:create_body_for_enrollment).and_return(data)
70
+ expect(@verification.verify_speaker(profileId, '/path/to/some/audio_file.wav')).to eql(@verify_speaker_result)
71
+ end
72
+ end
73
+
74
+ describe "#parse_error_response" do
75
+ it "throws an error" do
76
+ @verification.api_base_url = "http://localhost:11988/error"
77
+ expect { @verification.create_profile }.to raise_error(VoiceId::RequestHelpers::InvalidApiRequestError, "oh no everything's going wrong today!")
78
+ end
79
+ end
80
+ end
data/voice_id.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "voice_id"
3
+ s.version = "0.1.0"
4
+ s.date = "2016-09-16"
5
+ s.summary = "Ruby Wrapper for Microsoft Cognitive Services Speaker Recognition API"
6
+ s.description = "Exposes easy-to-use methods to work with Microsoft's Speach Recognition API and identify people by their voice. Useful for identifying your users by speech."
7
+ s.authors = ["Ali Yazdani"]
8
+ s.email = "aliyazdani82@gmail.com"
9
+ s.files = Dir["{lib,spec}/**/*", "[A-Z]*"] - ["Gemfile.lock"]
10
+ s.require_path = "lib"
11
+ s.homepage = "http://rubygems.org/gems/voice_id"
12
+ s.license = "MIT"
13
+
14
+ s.add_runtime_dependency "http", "~>2.0"
15
+ s.add_development_dependency "rspec", "~> 3.4"
16
+ s.add_development_dependency "mimic", "~> 0.4"
17
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: voice_id
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ali Yazdani
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-09-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: http
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: mimic
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ description: Exposes easy-to-use methods to work with Microsoft's Speach Recognition
56
+ API and identify people by their voice. Useful for identifying your users by speech.
57
+ email: aliyazdani82@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - Gemfile
63
+ - LICENSE
64
+ - Readme.md
65
+ - lib/voice_id.rb
66
+ - lib/voice_id/base.rb
67
+ - lib/voice_id/identification.rb
68
+ - lib/voice_id/request_helpers.rb
69
+ - lib/voice_id/utils.rb
70
+ - lib/voice_id/verification.rb
71
+ - spec/identification_spec.rb
72
+ - spec/mock_server.rb
73
+ - spec/spec_helper.rb
74
+ - spec/verification_spec.rb
75
+ - voice_id.gemspec
76
+ homepage: http://rubygems.org/gems/voice_id
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.5
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Ruby Wrapper for Microsoft Cognitive Services Speaker Recognition API
100
+ test_files: []