VoiceIt2 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/VoiceIt2.rb +427 -0
- metadata +44 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6057095000b5c1568678721d087354621e0be5c298caa534b5d44f6d44959d22
|
4
|
+
data.tar.gz: a1653d455a59e510d3235c3f6e7c74416af86197ca5107f2f0b9a462a50798db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6d9b0ebdeb85f4ed77f3307af6d5e680bd70e44c407ee62648e4b16225c47b69967d195956fa19f288c67e25c163a076b38ee3dd9a517d636ac04474b5ebd13b
|
7
|
+
data.tar.gz: 11ca42e4ddb25a3e7b6ec9d479cf498c65ee9500752d870f6884fd003f516b04d05fc2d1363bbe7c097dfdd3ed05128cd2846011c52e54377217459173202056
|
data/lib/VoiceIt2.rb
ADDED
@@ -0,0 +1,427 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rest_client'
|
3
|
+
|
4
|
+
class VoiceIt2
|
5
|
+
|
6
|
+
def initialize(key, tok)
|
7
|
+
@BASE_URL = URI('https://api.voiceit.io')
|
8
|
+
@api_key = key
|
9
|
+
@api_token = tok
|
10
|
+
end
|
11
|
+
|
12
|
+
def getAllUsers
|
13
|
+
return RestClient::Request.new(
|
14
|
+
:method => :get,
|
15
|
+
:url => @BASE_URL.to_s + '/users',
|
16
|
+
:user => @api_key,
|
17
|
+
:password => @api_token).execute
|
18
|
+
rescue => e
|
19
|
+
e.response
|
20
|
+
end
|
21
|
+
|
22
|
+
def createUser
|
23
|
+
return RestClient::Request.new(
|
24
|
+
:method => :post,
|
25
|
+
:url => @BASE_URL.to_s + '/users',
|
26
|
+
:user => @api_key,
|
27
|
+
:password => @api_token).execute
|
28
|
+
rescue => e
|
29
|
+
e.response
|
30
|
+
end
|
31
|
+
|
32
|
+
def getUser(userId)
|
33
|
+
return RestClient::Request.new(
|
34
|
+
:method => :get,
|
35
|
+
:url => @BASE_URL.to_s + '/users/' + userId,
|
36
|
+
:user => @api_key,
|
37
|
+
:password => @api_token).execute
|
38
|
+
rescue => e
|
39
|
+
e.response
|
40
|
+
end
|
41
|
+
|
42
|
+
def deleteUser(userId)
|
43
|
+
return RestClient::Request.new(
|
44
|
+
:method => :delete,
|
45
|
+
:url => @BASE_URL.to_s + '/users/' + userId,
|
46
|
+
:user => @api_key,
|
47
|
+
:password => @api_token).execute
|
48
|
+
rescue => e
|
49
|
+
e.response
|
50
|
+
end
|
51
|
+
|
52
|
+
def getGroupsForUser(userId)
|
53
|
+
return RestClient::Request.new(
|
54
|
+
:method => :get,
|
55
|
+
:url => @BASE_URL.to_s + '/users/' + userId + '/groups',
|
56
|
+
:user => @api_key,
|
57
|
+
:password => @api_token).execute
|
58
|
+
rescue => e
|
59
|
+
e.response
|
60
|
+
end
|
61
|
+
|
62
|
+
def getAllEnrollmentsForUser(userId)
|
63
|
+
return RestClient::Request.new(
|
64
|
+
:method => :get,
|
65
|
+
:url => @BASE_URL.to_s + '/enrollments/' + userId,
|
66
|
+
:user => @api_key,
|
67
|
+
:password => @api_token).execute
|
68
|
+
rescue => e
|
69
|
+
e.response
|
70
|
+
end
|
71
|
+
|
72
|
+
def deleteAllEnrollmentsForUser(userId)
|
73
|
+
return RestClient::Request.new(
|
74
|
+
:method => :delete,
|
75
|
+
:url => @BASE_URL.to_s + '/enrollments/' + userId + '/all',
|
76
|
+
:user => @api_key,
|
77
|
+
:password => @api_token).execute
|
78
|
+
rescue => e
|
79
|
+
e.response
|
80
|
+
end
|
81
|
+
|
82
|
+
def getFaceEnrollmentsForUser(userId)
|
83
|
+
return RestClient::Request.new(
|
84
|
+
:method => :get,
|
85
|
+
:url => @BASE_URL.to_s + '/enrollments/face/' + userId,
|
86
|
+
:user => @api_key,
|
87
|
+
:password => @api_token).execute
|
88
|
+
rescue => e
|
89
|
+
e.response
|
90
|
+
end
|
91
|
+
|
92
|
+
def createVoiceEnrollment(userId, contentLanguage, filePath)
|
93
|
+
return RestClient::Request.new(
|
94
|
+
:method => :post,
|
95
|
+
:url => @BASE_URL.to_s + '/enrollments',
|
96
|
+
:user => @api_key,
|
97
|
+
:password => @api_token,
|
98
|
+
:payload => {
|
99
|
+
:multipart => true,
|
100
|
+
:userId => userId,
|
101
|
+
:contentLanguage => contentLanguage,
|
102
|
+
:recording => File.new(filePath, 'rb')
|
103
|
+
}).execute
|
104
|
+
rescue => e
|
105
|
+
e.response
|
106
|
+
end
|
107
|
+
|
108
|
+
def createVoiceEnrollmentByUrl(userId, contentLanguage, fileUrl)
|
109
|
+
return RestClient::Request.new(
|
110
|
+
:method => :post,
|
111
|
+
:url => @BASE_URL.to_s + '/enrollments/byUrl',
|
112
|
+
:user => @api_key,
|
113
|
+
:password => @api_token,
|
114
|
+
:payload => {
|
115
|
+
:multipart => true,
|
116
|
+
:userId => userId,
|
117
|
+
:contentLanguage => contentLanguage,
|
118
|
+
:fileUrl => fileUrl
|
119
|
+
}).execute
|
120
|
+
rescue => e
|
121
|
+
e.response
|
122
|
+
end
|
123
|
+
|
124
|
+
def createFaceEnrollment(userId, filePath, doBlinkDetection = false)
|
125
|
+
return RestClient::Request.new(
|
126
|
+
:method => :post,
|
127
|
+
:url => @BASE_URL.to_s + '/enrollments/face',
|
128
|
+
:user => @api_key,
|
129
|
+
:password => @api_token,
|
130
|
+
:payload => {
|
131
|
+
:multipart => true,
|
132
|
+
:userId => userId,
|
133
|
+
:video => File.new(filePath, 'rb'),
|
134
|
+
:doBlinkDetection => doBlinkDetection
|
135
|
+
}).execute
|
136
|
+
rescue => e
|
137
|
+
e.response
|
138
|
+
end
|
139
|
+
|
140
|
+
def createVideoEnrollment(userId, contentLanguage, filePath, doBlinkDetection = false)
|
141
|
+
return RestClient::Request.new(
|
142
|
+
:method => :post,
|
143
|
+
:url => @BASE_URL.to_s + '/enrollments/video',
|
144
|
+
:user => @api_key,
|
145
|
+
:password => @api_token,
|
146
|
+
:payload => {
|
147
|
+
:multipart => true,
|
148
|
+
:userId => userId,
|
149
|
+
:contentLanguage => contentLanguage,
|
150
|
+
:video => File.new(filePath, 'rb'),
|
151
|
+
:doBlinkDetection => doBlinkDetection
|
152
|
+
}).execute
|
153
|
+
rescue => e
|
154
|
+
e.response
|
155
|
+
end
|
156
|
+
|
157
|
+
def createVideoEnrollmentByUrl(userId, contentLanguage, fileUrl, doBlinkDetection = false)
|
158
|
+
return RestClient::Request.new(
|
159
|
+
:method => :post,
|
160
|
+
:url => @BASE_URL.to_s + '/enrollments/video/byUrl',
|
161
|
+
:user => @api_key,
|
162
|
+
:password => @api_token,
|
163
|
+
:payload => {
|
164
|
+
:multipart => true,
|
165
|
+
:userId => userId,
|
166
|
+
:contentLanguage => contentLanguage,
|
167
|
+
:fileUrl => fileUrl,
|
168
|
+
:doBlinkDetection => doBlinkDetection
|
169
|
+
}).execute
|
170
|
+
rescue => e
|
171
|
+
e.response
|
172
|
+
end
|
173
|
+
|
174
|
+
def deleteFaceEnrollment(userId, faceEnrollmentId)
|
175
|
+
return RestClient::Request.new(
|
176
|
+
:method => :delete,
|
177
|
+
:url => @BASE_URL.to_s + '/enrollments/face/' + userId + '/' + faceEnrollmentId,
|
178
|
+
:user => @api_key,
|
179
|
+
:password => @api_token).execute
|
180
|
+
rescue => e
|
181
|
+
e.response
|
182
|
+
end
|
183
|
+
|
184
|
+
def deleteEnrollmentForUser(userId, enrollmentId)
|
185
|
+
return RestClient::Request.new(
|
186
|
+
:method => :delete,
|
187
|
+
:url => @BASE_URL.to_s + '/enrollments/' + userId + '/' + enrollmentId,
|
188
|
+
:user => @api_key,
|
189
|
+
:password => @api_token).execute
|
190
|
+
rescue => e
|
191
|
+
e.response
|
192
|
+
end
|
193
|
+
|
194
|
+
def getAllGroups()
|
195
|
+
return RestClient::Request.new(
|
196
|
+
:method => :get,
|
197
|
+
:url => @BASE_URL.to_s + '/groups',
|
198
|
+
:user => @api_key,
|
199
|
+
:password => @api_token).execute
|
200
|
+
rescue => e
|
201
|
+
e.response
|
202
|
+
end
|
203
|
+
|
204
|
+
def getGroup(groupId)
|
205
|
+
return RestClient::Request.new(
|
206
|
+
:method => :get,
|
207
|
+
:url => @BASE_URL.to_s + '/groups/' + groupId,
|
208
|
+
:user => @api_key,
|
209
|
+
:password => @api_token).execute
|
210
|
+
rescue => e
|
211
|
+
e.response
|
212
|
+
end
|
213
|
+
|
214
|
+
def groupExists(groupId)
|
215
|
+
return RestClient::Request.new(
|
216
|
+
:method => :get,
|
217
|
+
:url => @BASE_URL.to_s + '/groups/' + groupId + '/exists',
|
218
|
+
:user => @api_key,
|
219
|
+
:password => @api_token).execute
|
220
|
+
rescue => e
|
221
|
+
e.response
|
222
|
+
end
|
223
|
+
|
224
|
+
def createGroup(description)
|
225
|
+
return RestClient::Request.new(
|
226
|
+
:method => :post,
|
227
|
+
:url => @BASE_URL.to_s + '/groups',
|
228
|
+
:user => @api_key,
|
229
|
+
:password => @api_token,
|
230
|
+
:payload => {
|
231
|
+
:multipart => true,
|
232
|
+
:description => description
|
233
|
+
}).execute
|
234
|
+
rescue => e
|
235
|
+
e.response
|
236
|
+
end
|
237
|
+
|
238
|
+
def addUserToGroup(groupId, userId)
|
239
|
+
return RestClient::Request.new(
|
240
|
+
:method => :put,
|
241
|
+
:url => @BASE_URL.to_s + '/groups/addUser',
|
242
|
+
:user => @api_key,
|
243
|
+
:password => @api_token,
|
244
|
+
:payload => {
|
245
|
+
:multipart => true,
|
246
|
+
:groupId => groupId,
|
247
|
+
:userId => userId
|
248
|
+
}).execute
|
249
|
+
rescue => e
|
250
|
+
e.response
|
251
|
+
end
|
252
|
+
|
253
|
+
def removeUserFromGroup(groupId, userId)
|
254
|
+
return RestClient::Request.new(
|
255
|
+
:method => :put,
|
256
|
+
:url => @BASE_URL.to_s + '/groups/removeUser',
|
257
|
+
:user => @api_key,
|
258
|
+
:password => @api_token,
|
259
|
+
:payload => {
|
260
|
+
:multipart => true,
|
261
|
+
:groupId => groupId,
|
262
|
+
:userId => userId
|
263
|
+
}).execute
|
264
|
+
rescue => e
|
265
|
+
e.response
|
266
|
+
end
|
267
|
+
|
268
|
+
def deleteGroup(groupId)
|
269
|
+
return RestClient::Request.new(
|
270
|
+
:method => :delete,
|
271
|
+
:url => @BASE_URL.to_s + '/groups/' + groupId,
|
272
|
+
:user => @api_key,
|
273
|
+
:password => @api_token).execute
|
274
|
+
rescue => e
|
275
|
+
e.response
|
276
|
+
end
|
277
|
+
|
278
|
+
def voiceVerification(userId, contentLanguage, filePath)
|
279
|
+
return RestClient::Request.new(
|
280
|
+
:method => :post,
|
281
|
+
:url => @BASE_URL.to_s + '/verification',
|
282
|
+
:user => @api_key,
|
283
|
+
:password => @api_token,
|
284
|
+
:payload => {
|
285
|
+
:multipart => true,
|
286
|
+
:userId => userId,
|
287
|
+
:contentLanguage => contentLanguage,
|
288
|
+
:recording => File.new(filePath, 'rb')
|
289
|
+
}).execute
|
290
|
+
rescue => e
|
291
|
+
e.response
|
292
|
+
end
|
293
|
+
|
294
|
+
def voiceVerificationByUrl(userId, contentLanguage, fileUrl)
|
295
|
+
return RestClient::Request.new(
|
296
|
+
:method => :post,
|
297
|
+
:url => @BASE_URL.to_s + '/verification/byUrl',
|
298
|
+
:user => @api_key,
|
299
|
+
:password => @api_token,
|
300
|
+
:payload => {
|
301
|
+
:multipart => true,
|
302
|
+
:userId => userId,
|
303
|
+
:contentLanguage => contentLanguage,
|
304
|
+
:fileUrl => fileUrl
|
305
|
+
}).execute
|
306
|
+
rescue => e
|
307
|
+
e.response
|
308
|
+
end
|
309
|
+
|
310
|
+
def faceVerification(userId, filePath, doBlinkDetection = false)
|
311
|
+
return RestClient::Request.new(
|
312
|
+
:method => :post,
|
313
|
+
:url => @BASE_URL.to_s + '/verification/face',
|
314
|
+
:user => @api_key,
|
315
|
+
:password => @api_token,
|
316
|
+
:payload => {
|
317
|
+
:multipart => true,
|
318
|
+
:userId => userId,
|
319
|
+
:doBlinkDetection => doBlinkDetection,
|
320
|
+
:video => File.new(filePath, 'rb')
|
321
|
+
}).execute
|
322
|
+
rescue => e
|
323
|
+
e.response
|
324
|
+
end
|
325
|
+
|
326
|
+
def videoVerification(userId, contentLanguage, filePath, doBlinkDetection = false)
|
327
|
+
return RestClient::Request.new(
|
328
|
+
:method => :post,
|
329
|
+
:url => @BASE_URL.to_s + '/verification/video',
|
330
|
+
:user => @api_key,
|
331
|
+
:password => @api_token,
|
332
|
+
:payload => {
|
333
|
+
:multipart => true,
|
334
|
+
:userId => userId,
|
335
|
+
:contentLanguage => contentLanguage,
|
336
|
+
:doBlinkDetection => doBlinkDetection,
|
337
|
+
:video => File.new(filePath, 'rb')
|
338
|
+
}).execute
|
339
|
+
rescue => e
|
340
|
+
e.response
|
341
|
+
end
|
342
|
+
|
343
|
+
def videoVerificationByUrl(userId, contentLanguage, fileUrl, doBlinkDetection = false)
|
344
|
+
return RestClient::Request.new(
|
345
|
+
:method => :post,
|
346
|
+
:url => @BASE_URL.to_s + '/verification/video/byUrl',
|
347
|
+
:user => @api_key,
|
348
|
+
:password => @api_token,
|
349
|
+
:payload => {
|
350
|
+
:multipart => true,
|
351
|
+
:userId => userId,
|
352
|
+
:contentLanguage => contentLanguage,
|
353
|
+
:doBlinkDetection => doBlinkDetection,
|
354
|
+
:fileUrl => fileUrl
|
355
|
+
}).execute
|
356
|
+
rescue => e
|
357
|
+
e.response
|
358
|
+
end
|
359
|
+
|
360
|
+
def voiceIdentification(groupId, contentLanguage, filePath)
|
361
|
+
return RestClient::Request.new(
|
362
|
+
:method => :post,
|
363
|
+
:url => @BASE_URL.to_s + '/identification',
|
364
|
+
:user => @api_key,
|
365
|
+
:password => @api_token,
|
366
|
+
:payload => {
|
367
|
+
:multipart => true,
|
368
|
+
:groupId => groupId,
|
369
|
+
:contentLanguage => contentLanguage,
|
370
|
+
:recording => File.new(filePath, 'rb')
|
371
|
+
}).execute
|
372
|
+
rescue => e
|
373
|
+
e.response
|
374
|
+
end
|
375
|
+
|
376
|
+
def voiceIdentificationByUrl(groupId, contentLanguage, fileUrl)
|
377
|
+
return RestClient::Request.new(
|
378
|
+
:method => :post,
|
379
|
+
:url => @BASE_URL.to_s + '/identification/byUrl',
|
380
|
+
:user => @api_key,
|
381
|
+
:password => @api_token,
|
382
|
+
:payload => {
|
383
|
+
:multipart => true,
|
384
|
+
:groupId => groupId,
|
385
|
+
:contentLanguage => contentLanguage,
|
386
|
+
:fileUrl => fileUrl
|
387
|
+
}).execute
|
388
|
+
rescue => e
|
389
|
+
e.response
|
390
|
+
end
|
391
|
+
|
392
|
+
def videoIdentification(groupId, contentLanguage, filePath, doBlinkDetection = false)
|
393
|
+
return RestClient::Request.new(
|
394
|
+
:method => :post,
|
395
|
+
:url => @BASE_URL.to_s + '/identification/video',
|
396
|
+
:user => @api_key,
|
397
|
+
:password => @api_token,
|
398
|
+
:payload => {
|
399
|
+
:multipart => true,
|
400
|
+
:groupId => groupId,
|
401
|
+
:contentLanguage => contentLanguage,
|
402
|
+
:doBlinkDetection => doBlinkDetection,
|
403
|
+
:video => File.new(filePath, 'rb')
|
404
|
+
}).execute
|
405
|
+
rescue => e
|
406
|
+
e.response
|
407
|
+
end
|
408
|
+
|
409
|
+
def videoIdentificationByUrl(groupId, contentLanguage, fileUrl, doBlinkDetection = false)
|
410
|
+
return RestClient::Request.new(
|
411
|
+
:method => :post,
|
412
|
+
:url => @BASE_URL.to_s + '/identification/video/byUrl',
|
413
|
+
:user => @api_key,
|
414
|
+
:password => @api_token,
|
415
|
+
:payload => {
|
416
|
+
:multipart => true,
|
417
|
+
:groupId => groupId,
|
418
|
+
:contentLanguage => contentLanguage,
|
419
|
+
:doBlinkDetection => doBlinkDetection,
|
420
|
+
:fileUrl => fileUrl
|
421
|
+
}).execute
|
422
|
+
rescue => e
|
423
|
+
e.response
|
424
|
+
end
|
425
|
+
|
426
|
+
|
427
|
+
end
|
metadata
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: VoiceIt2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- StephenAkers
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-31 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A wrapper fro VoiceIt's API 2
|
14
|
+
email: stephen@voiceit.io
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/VoiceIt2.rb
|
20
|
+
homepage: http://rubygems.org/gems/hola
|
21
|
+
licenses:
|
22
|
+
- MIT
|
23
|
+
metadata: {}
|
24
|
+
post_install_message:
|
25
|
+
rdoc_options: []
|
26
|
+
require_paths:
|
27
|
+
- lib
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
requirements: []
|
39
|
+
rubyforge_project:
|
40
|
+
rubygems_version: 2.7.6
|
41
|
+
signing_key:
|
42
|
+
specification_version: 4
|
43
|
+
summary: VoiceIt Api 2
|
44
|
+
test_files: []
|