def __init__(self, subkey="", token=""):
        """if the subkey is empty, it means that the object will be created using a temporary 
		user token instead of an admin key,token pair. 
		"""
        if subkey == "":
            self.vt = VoiceIt2(token, "")
        else:
            self.vt = VoiceIt2(subkey, token)
Example #2
0
 def tearDownClass(cls):
     global groups_to_delete, users_to_delete
     my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
     for user_id in users_to_delete:
         my_voiceit.delete_user(user_id)
     for group_id in groups_to_delete:
         my_voiceit.delete_group(group_id)
Example #3
0
    def test_sub_accounts(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        print('Testing Sub Account API Calls')

        print('   Testing Create Unmanaged Sub Account')
        ret = my_voiceit.create_unmanaged_sub_account("Test", "Python", "", "",
                                                      "")
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        unmanaged_sub_account = ret['apiKey']

        ret = my_voiceit.switch_sub_account_type(ret['apiKey'])
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Testing Create Managed Sub Account')
        ret = my_voiceit.create_managed_sub_account("Test", "Python", "", "",
                                                    "")
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        managed_sub_account = ret['apiKey']

        print('   Testing Regenerate Sub Account API Token')
        ret = my_voiceit.regenerate_sub_account_api_token(
            unmanaged_sub_account)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Testing Delete Sub Account')
        ret = my_voiceit.delete_sub_account(unmanaged_sub_account)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        ret = my_voiceit.delete_sub_account(managed_sub_account)
Example #4
0
def create_user(request):
    api_key = 'key_66f6eb3dbd0c4d7d85bf9e716b3813f4'
    api_token = 'tok_eff69e97da604bf7a6d13b8ed1400ce9'
    my_voiceit = VoiceIt2(api_key, api_token)
    my_voiceit.create_user()
    my_voiceit.add_user_to_group("grp_b3f953e210494f5db673bbd520ff79d8",
                                 "usr_361ea5aa209047189cc7222ff249a4e5")
Example #5
0
    def test_file_not_found(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        print('Testing File Not Found')
        print('   Testing File Not Found Enrollment')
        try:
            my_voiceit.create_voice_enrollment('', CONTENT_LANGUAGE, PHRASE, './nonexistent.wav')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        try:
            my_voiceit.create_face_enrollment('', './nonexistent.mov')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        try:
            my_voiceit.create_video_enrollment('', CONTENT_LANGUAGE, PHRASE, './nonexistent.mov')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        print('   Testing File Not Found Verification')
        try:
            my_voiceit.voice_verification('', CONTENT_LANGUAGE, PHRASE, './nonexistent.wav')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        try:
            my_voiceit.face_verification('', './nonexistent.mov')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        try:
            my_voiceit.video_verification('', CONTENT_LANGUAGE, PHRASE, './nonexistent.mov')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        print('   Testing File Not Found Identification')
        try:
            my_voiceit.voice_identification('', CONTENT_LANGUAGE, PHRASE, './nonexistent.wav')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        try:
            my_voiceit.face_identification('', './nonexistent.mov')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)

        try:
            my_voiceit.video_identification('', CONTENT_LANGUAGE, PHRASE, './nonexistent.mov')
            self.assertTrue(False)
        except IOError:
            self.assertTrue(True)
Example #6
0
    def test_verification(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        user_id = my_voiceit.create_user()['userId']
        users_to_delete.append(user_id)
        # Create 3 voice,face and video enrollments for user
        my_voiceit.create_voice_enrollment(user_id, CONTENT_LANGUAGE, PHRASE,
                                           './enrollmentA1.wav')
        my_voiceit.create_voice_enrollment(user_id, CONTENT_LANGUAGE, PHRASE,
                                           './enrollmentA2.wav')
        my_voiceit.create_voice_enrollment(user_id, CONTENT_LANGUAGE, PHRASE,
                                           './enrollmentA3.wav')
        my_voiceit.create_face_enrollment(user_id, './faceEnrollmentB1.mp4')
        my_voiceit.create_face_enrollment(user_id, './faceEnrollmentB2.mp4')
        my_voiceit.create_face_enrollment(user_id, './faceEnrollmentB3.mp4')
        my_voiceit.create_video_enrollment(user_id, CONTENT_LANGUAGE, PHRASE,
                                           './videoEnrollmentB1.mov')
        my_voiceit.create_video_enrollment(user_id, CONTENT_LANGUAGE, PHRASE,
                                           './videoEnrollmentB2.mov')
        my_voiceit.create_video_enrollment(user_id, CONTENT_LANGUAGE, PHRASE,
                                           './videoEnrollmentB3.mov')

        print('Test Verification API Calls')

        print('   Test Voice Verification')
        ret = my_voiceit.voice_verification(user_id, CONTENT_LANGUAGE, PHRASE,
                                            './verificationA1.wav')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Voice Verification by URL')
        ret = my_voiceit.voice_verification_by_url(
            user_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'enrollmentA4.wav')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Face Verification')
        ret = my_voiceit.face_verification(user_id, './faceVerificationB1.mp4')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Face Verification by URL')
        ret = my_voiceit.face_verification_by_url(
            user_id, VOICEIT_DRIVE_URL + 'faceVerificationB1.mp4')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Video Verification')
        ret = my_voiceit.video_verification(user_id, CONTENT_LANGUAGE, PHRASE,
                                            './videoVerificationB1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Video Verification by URL')
        ret = my_voiceit.video_verification_by_url(
            user_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'videoVerificationB2.mp4')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
Example #7
0
    def test_phrases(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        print('Testing Phrase API Calls')

        print('   Testing Get Phrases')
        ret = my_voiceit.get_phrases('en-US')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertGreaterEqual(len(ret['phrases']), 0)
Example #8
0
def voiceit_enroll_user(user_id, file_path, phrase):
    my_voiceit = VoiceIt2(api_key, api_token)
    # user_id = 'usr_afca986a9db2473d932228735d298957'  #
    content_language = 'en-US'
    video = open(file_path, 'rb')
    response = my_voiceit.create_video_enrollment(user_id=user_id,
                                                  lang=content_language,
                                                  phrase=phrase,
                                                  file_buffer=video)
    return response['responseCode']
Example #9
0
def voiceit_create_user(group_id, user):
    my_voiceit = VoiceIt2(api_key, api_token)
    response = my_voiceit.create_user()
    os.mkdir(os.path.join(BASE_DIR, 'test', str(user.id)))
    response2 = my_voiceit.group_exists(group_id)  #
    if response2['exists']:
        my_voiceit.add_user_to_group(group_id, response['userId'])
        return [True, response['userId']]
    else:
        return [False, response['userId']]
Example #10
0
 def facial(url):  # s3 data
     # --------
     id_user = url.split("users")[1].split('/')[1]
     my_voiceit = VoiceIt2(apiKey, apiToken)
     r = my_voiceit.face_verification_by_url(id_user, url)
     return {
         "facial": "aprovado"
     } if r['faceConfidence'] > 95 else {
         "facial": "reprovado"
     }
Example #11
0
 def test_webhooks(self):
     print('Testing Notification URL')
     my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
     if os.environ['BOXFUSE_ENV'] == 'voiceittest':
         text_file = open(os.environ['HOME'] + '/platformVersion', "w")
         text_file.write(my_voiceit.version)
         text_file.close()
     my_voiceit.add_notification_url('https://voiceit.io')
     self.assertEqual(my_voiceit.notification_url, '?notificationURL=https%3A%2F%2Fvoiceit.io')
     my_voiceit.remove_notification_url()
     self.assertEqual(my_voiceit.notification_url, '')
Example #12
0
 def facial(cpf, url):  # s3 data
     # --------
     id_user = url.split("users")[1].split('/')[1]
     my_voiceit = VoiceIt2(apiKey, apiToken)
     r = my_voiceit.face_verification_by_url(id_user, url)
     status = {
         "facial": "aprovado"
     } if r['faceConfidence'] > 95 else {
         "facial": "reprovado"
     }
     status['cpf'] = cpf
     result = CRUD.update(status)
     return status
Example #13
0
def voiceit_identification(request):
    my_voiceit = VoiceIt2(api_key, api_token)
    group_id = 'gid'  #
    content_language = 'en-US'
    phrase = 'my face and voice identify me'
    video = open('siddharth1.mp4', 'rb')
    response = my_voiceit.voice_identification(group_id=group_id,
                                               lang=content_language,
                                               phrase=phrase,
                                               file_buffer=video)
    if response['responseCode'] == 'SUCC':
        return [True, response['user_id']]
    else:
        return [False, response['message']]
Example #14
0
def voiceit_verification(user_id, file_path, phrase):
    my_voiceit = VoiceIt2(api_key, api_token)  #
    content_language = 'en-US'
    video = open(file_path, 'rb')
    response = my_voiceit.video_verification(user_id=user_id,
                                             lang=content_language,
                                             phrase=phrase,
                                             file_buffer=video)
    if response['voiceConfidence'] > 50 and response[
            'faceConfidence'] > 50 and response['textConfidence'] > 50:
        return [True, response['message']]

    if response['responseCode'] == 'SUCC':
        return [True, response['message']]
    else:
        return [False, response['message']]
Example #15
0
    def test_groups(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        global groups_to_delete, users_to_delete
        print('Test Group API Calls')

        print('   Test Create Group')
        ret = my_voiceit.create_group('Sample Group Description')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        group_id = ret['groupId']
        groups_to_delete.append(group_id)

        print('   Test Get Group')
        ret = my_voiceit.get_group(group_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Get All Groups')
        ret = my_voiceit.get_all_groups()
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertGreaterEqual(len(ret['groups']), 0)

        print('   Test Group Exists')
        ret = my_voiceit.group_exists(group_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(True, ret['exists'])

        user_id = my_voiceit.create_user()['userId']
        users_to_delete.append(user_id)

        print('   Test Add User to Group')
        ret = my_voiceit.add_user_to_group(group_id, user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Remove User from Group')
        ret = my_voiceit.remove_user_from_group(group_id, user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Delete Group')
        ret = my_voiceit.delete_group(group_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
Example #16
0
    def test_users(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        global users_to_delete
        print('Testing User API Calls')

        print('   Testing Get All Users')
        ret = my_voiceit.get_all_users()
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertGreaterEqual(len(ret['users']), 0)

        print('   Testing Create User')
        ret = my_voiceit.create_user()
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        user_id = ret['userId']
        users_to_delete.append(user_id)

        print('   Testing Check User Exists')
        ret = my_voiceit.check_user_exists(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Testing Get Groups For User')
        ret = my_voiceit.get_groups_for_user(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(
            0, len(my_voiceit.get_groups_for_user(user_id)['groups']))

        print('   Testing Create User Token')
        ret = my_voiceit.create_user_token(user_id, 5)
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Testing Expire User Tokens')
        ret = my_voiceit.expire_user_tokens(user_id)
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Testing Delete User')
        ret = my_voiceit.delete_user(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
Example #17
0
 def tearDownClass(cls):
     global groups_to_delete, users_to_delete
     my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
     for user_id in users_to_delete:
         my_voiceit.delete_user(user_id)
     for group_id in groups_to_delete:
         my_voiceit.delete_group(group_id)
     os.remove('./enrollmentBMyFaceAndVoice.m4a')
     os.remove('./enrollmentA1.wav')
     os.remove('./enrollmentA2.wav')
     os.remove('./enrollmentA3.wav')
     os.remove('./enrollmentA4.wav')
     os.remove('./verificationA1.wav')
     os.remove('./enrollmentC2.wav')
     os.remove('./enrollmentC3.wav')
     os.remove('./enrollmentD1.m4a')
     os.remove('./enrollmentD2.m4a')
     os.remove('./enrollmentD3.m4a')
     os.remove('./verificationD1.m4a')
     os.remove('./videoEnrollmentB1.mov')
     os.remove('./videoEnrollmentB2.mov')
     os.remove('./videoEnrollmentB3.mov')
     os.remove('./videoVerificationB1.mov')
     os.remove('./videoEnrollmentC2.mov')
     os.remove('./videoEnrollmentC3.mov')
     os.remove('./faceEnrollmentB1.mp4')
     os.remove('./faceEnrollmentB2.mp4')
     os.remove('./faceEnrollmentB3.mp4')
     os.remove('./faceVerificationB1.mp4')
     os.remove('./faceEnrollmentA1.mov')
     os.remove('./faceEnrollmentA2.mov')
     os.remove('./faceEnrollmentA3.mov')
     os.remove('./videoEnrollmentA1.mov')
     os.remove('./videoEnrollmentA2.mov')
     os.remove('./videoEnrollmentA3.mov')
     os.remove('./videoEnrollmentD1.mov')
     os.remove('./videoEnrollmentD2.mov')
     os.remove('./videoEnrollmentD3.mov')
     os.remove('./videoVerificationD1.mov')
Example #18
0
def enroll_user(request):
    api_key = 'key_66f6eb3dbd0c4d7d85bf9e716b3813f4'
    api_token = 'tok_eff69e97da604bf7a6d13b8ed1400ce9'
    my_voiceit = VoiceIt2(api_key, api_token)
    user_id = 'usr_afca986a9db2473d932228735d298957'
    content_language = 'en-US'
    phrase = 'my face and voice identify me'
    video = open('siddharth1.mp4', 'rb')
    my_voiceit.create_video_enrollment(user_id=user_id,
                                       lang=content_language,
                                       phrase=phrase,
                                       file_buffer=video)
    video = open('prashant2.mp4', 'rb')
    my_voiceit.create_video_enrollment(user_id=user_id,
                                       lang=content_language,
                                       phrase=phrase,
                                       file_buffer=video)
    video = open('prashant3.mp4', 'rb')
    my_voiceit.create_video_enrollment(user_id=user_id,
                                       lang=content_language,
                                       phrase=phrase,
                                       file_buffer=video)
Example #19
0
    def test_enrollments(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        ret = my_voiceit.create_user()
        user_id = my_voiceit.create_user()['userId']
        users_to_delete.append(user_id)
        print('Test Enrollment API Calls')

        print('   Test Get All Face Enrollments')
        ret = my_voiceit.get_all_face_enrollments(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertGreaterEqual(len(ret['faceEnrollments']), 0)

        print('   Test Get All Voice Enrollments')
        ret = my_voiceit.get_all_voice_enrollments(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertGreaterEqual(len(ret['voiceEnrollments']), 0)

        print('   Test Get All Video Enrollments')
        ret = my_voiceit.get_all_video_enrollments(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertGreaterEqual(len(ret['videoEnrollments']), 0)

        print('   Test Create Voice Enrollment')
        ret = my_voiceit.create_voice_enrollment(user_id, CONTENT_LANGUAGE,
                                                 PHRASE, './enrollmentA1.wav')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        enrollment_id_to_delete = ret['id']

        print('   Test Create Voice Enrollment by URL')
        ret = my_voiceit.create_voice_enrollment_by_url(
            user_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'enrollmentA2.wav')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Create Face Enrollment')
        ret = my_voiceit.create_face_enrollment(user_id,
                                                './faceEnrollmentA1.mov')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        enrollment_id_to_delete = ret['faceEnrollmentId']

        print('   Test Create Face Enrollment by URL')
        ret = my_voiceit.create_face_enrollment_by_url(
            user_id, VOICEIT_DRIVE_URL + 'faceEnrollmentA2.mov')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Create Video Enrollment')
        ret = my_voiceit.create_video_enrollment(user_id, CONTENT_LANGUAGE,
                                                 PHRASE,
                                                 './videoEnrollmentA1.mov')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        enrollment_id_to_delete = ret['id']

        print('   Test Create Video Enrollment by URL')
        ret = my_voiceit.create_video_enrollment_by_url(
            user_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'videoEnrollmentA2.mov')
        self.assertEqual(201, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])

        print('   Test Delete All Enrollments')
        ret = my_voiceit.delete_all_enrollments(user_id)
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
import enum
import os
from typing import Optional

from voiceit2 import VoiceIt2
import yaml

from app.voiceit_verification.config import LANG, VERIFICATION_PHRASE, KEY, TOKEN

app = VoiceIt2(KEY, TOKEN)
path = os.path.join(os.path.dirname(os.path.abspath(__file__)))


class VerificationStatus(enum.Enum):
    SUCC = 1,
    FAIL = 2,


def parse_verification_response(response: dict):
    """
    Парсит ответ от Voiceit API
    :param response:
    :return:
    """
    response_code = response.get("responseCode")
    if response_code == "SUCC":
        return VerificationStatus.SUCC
    return VerificationStatus.FAIL


def verify_user(user_name: str, file: str) -> VerificationStatus:
Example #21
0
from voiceit2 import VoiceIt2

# users can be given their token to authenticate, so that they don't have use developers' keys and tokens
# if using token authentication: voiceit = VoiceIt2("user_token", "")
# only allows to API calls related to that user
voiceit = VoiceIt2("key_d79251d085214874b7479cdf67cd40b8", "tok_3f628df367944320a359510086825836")

#alternative url that receives results of API calls
voiceit.add_notification_url("some url")

# all approved phrases for verification
my_voiceit.get_phrases("en-CA") # could be en-US

voiceit.get_all_users()

voiceit.create_user()

voiceit.check_user_exists("userId")

voiceit.get_groups_for_user("userId")

voiceit.create_user_token("<userId>", "secs to timeout")

voiceit.expire_user_tokens("userId")

# group methods: get_all(), check_exists("groupId"), get_group("gid"), create_group("description")
# add_user_to_group(gid, uid), remove_user_from_group(gid, uid), delete_group("gid")


Example #22
0
from voiceit2 import VoiceIt2

import random

import sounddevice as sd
import soundfile as sf

items = ['Zoos are filled with small and large animals']
key = 'key_069d3c61a7ce4adf9d4136e6c46d0be7'
tokenId = 'tok_9dee93cae2e54688863186d14522da2e'
userId = 'usr_c57ba85ee0cb466d8add6127b55835b9'

rand_item = items[random.randrange(len(items))]
print("Your OTP is:")
print(rand_item)
my_voiceit = VoiceIt2(key, tokenId)

filename = "C:\\Users\\Win10\\Desktop\\voiceit\\voiceit2\\4.wav"

print(my_voiceit.voice_verification(userId, "en-US", rand_item, filename))
Example #23
0
def voiceit_create_group(request):
    my_voiceit = VoiceIt2(api_key, api_token)
    description = "Developer"
    response = my_voiceit.create_group(description)
    return response['groupId']
Example #24
0
    def test_identification(self):
        my_voiceit = VoiceIt2(VI_KEY, VI_TOKEN)
        global groups_to_delete, users_to_delete
        print('Start Identification Setup...')
        user_id_1 = my_voiceit.create_user()['userId']
        users_to_delete.append(user_id_1)
        user_id_2 = my_voiceit.create_user()['userId']
        users_to_delete.append(user_id_2)
        group_id = my_voiceit.create_group(
            'Test Identification Group')['groupId']
        groups_to_delete.append(group_id)
        my_voiceit.add_user_to_group(group_id, user_id_1)
        my_voiceit.add_user_to_group(group_id, user_id_2)

        # Create 3 voice enrollments for each user
        for file in [
                './enrollmentA1.wav', './enrollmentA2.wav',
                './enrollmentA3.wav'
        ]:
            my_voiceit.create_voice_enrollment(user_id_1, CONTENT_LANGUAGE,
                                               PHRASE, file)
        for file in [
                './enrollmentD1.m4a', './enrollmentD2.m4a',
                './enrollmentD3.m4a'
        ]:
            my_voiceit.create_voice_enrollment(user_id_2, CONTENT_LANGUAGE,
                                               PHRASE, file)
        # Create 3 video enrollments for each user
        for file in [
                './videoEnrollmentB1.mov', './videoEnrollmentB2.mov',
                './videoEnrollmentB3.mov'
        ]:
            my_voiceit.create_video_enrollment(user_id_1, CONTENT_LANGUAGE,
                                               PHRASE, file)
        for file in [
                './videoEnrollmentD1.mov', './videoEnrollmentD2.mov',
                './videoEnrollmentD3.mov'
        ]:
            my_voiceit.create_video_enrollment(user_id_2, CONTENT_LANGUAGE,
                                               PHRASE, file)

        print('Test Identification API Calls')

        print('   Test Voice Identification')
        ret = my_voiceit.voice_identification(group_id, CONTENT_LANGUAGE,
                                              PHRASE, './enrollmentA4.wav')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_1, ret['userId'])
        ret = my_voiceit.voice_identification(group_id, CONTENT_LANGUAGE,
                                              PHRASE, './verificationD1.m4a')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_2, ret['userId'])

        print('   Test Voice Identification by URL')
        ret = my_voiceit.voice_identification_by_url(
            group_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'verificationA1.wav')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_1, ret['userId'])
        ret = my_voiceit.voice_identification_by_url(
            group_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'verificationD1.m4a')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_2, ret['userId'])

        print('   Test Face Identification')
        ret = my_voiceit.face_identification(group_id,
                                             './faceVerificationB1.mp4')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_1, ret['userId'])
        ret = my_voiceit.face_identification(group_id,
                                             './videoVerificationD1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_2, ret['userId'])

        print('   Test Face Identification by URL')
        ret = my_voiceit.face_identification_by_url(
            group_id, VOICEIT_DRIVE_URL + 'faceVerificationB1.mp4')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_1, ret['userId'])
        ret = my_voiceit.face_identification_by_url(
            group_id, VOICEIT_DRIVE_URL + 'videoEnrollmentD1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_2, ret['userId'])

        print('   Test Video Identification')
        ret = my_voiceit.video_identification(group_id, CONTENT_LANGUAGE,
                                              PHRASE,
                                              './videoVerificationB1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_1, ret['userId'])
        ret = my_voiceit.video_identification(group_id, CONTENT_LANGUAGE,
                                              PHRASE,
                                              './videoVerificationD1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_2, ret['userId'])

        print('   Test Video Identification by URL')
        ret = my_voiceit.video_identification_by_url(
            group_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'videoVerificationB1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_1, ret['userId'])
        ret = my_voiceit.video_identification_by_url(
            group_id, CONTENT_LANGUAGE, PHRASE,
            VOICEIT_DRIVE_URL + 'videoVerificationD1.mov')
        self.assertEqual(200, ret['status'])
        self.assertEqual('SUCC', ret['responseCode'])
        self.assertEqual(user_id_2, ret['userId'])
Example #25
0
import dataset
from voiceit2 import VoiceIt2

from console_logging.console import Console
import os
console = Console()

console.log("Stating....")

apiKey = "   "  #
apiToken = "  "

my_voiceit = VoiceIt2(apiKey, apiToken)

try:
    #ENDPOINT_DB = os.getenv('ENDPOINT_DB')
    #db = dataset.connect(ENDPOINT_DB)
    db = dataset.connect('sqlite:///tovivo.db')

except:
    db = dataset.connect('sqlite:///tovivo.db')


class CRUD:
    @staticmethod
    def cadastrar(data):
        table = db['user']
        user = my_voiceit.create_user()
        print(user)
        data['userId'] = user['userId']
        table.insert(data)
Example #26
0
    frames.append(data)
print("finished recording")

# stop Recording
stream.stop_stream()
stream.close()
audio.terminate()

waveFile = wave.open(WAVE_OUTPUT_FILENAME, 'wb')
waveFile.setnchannels(CHANNELS)
waveFile.setsampwidth(audio.get_sample_size(FORMAT))
waveFile.setframerate(RATE)
waveFile.writeframes(b''.join(frames))
waveFile.close()

my_voiceit = VoiceIt2('key_95dc2f49e21d462e9cc03c5a4ba7a076',
                      'tok_ff1b7e2e26db42f8b2ee9af8e2e0e109')
my_voiceit.create_voice_enrollment(
    "usr_b9c994a6bc4149968eab59c6c9ca085b", "en-US",
    "hey jarvis you up initiate boot sequence two user stark", "auth3.wav")

print("say hey jarvis deactivate suit mark one actavation code user stark")
FORMAT = pyaudio.paInt16
CHANNELS = 2
RATE = 44100
CHUNK = 1024
RECORD_SECONDS = 9
WAVE_OUTPUT_FILENAME = "auth.wav"

audio = pyaudio.PyAudio()

# start Recording
from voiceit2 import VoiceIt2


import random

import sounddevice as sd
import soundfile as sf
import re



my_voiceit = VoiceIt2('key_069d3c61a7ce4adf9d4136e6c46d0be7','tok_9dee93cae2e54688863186d14522da2e')
user1 = my_voiceit.create_user()
print(user1['userId'])