-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_example.php
More file actions
31 lines (25 loc) · 1.02 KB
/
test_example.php
File metadata and controls
31 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
include 'voiceit/VoiceIt3.php';
$vi = new VoiceIt\VoiceIt3(getenv('VOICEIT_API_KEY'), getenv('VOICEIT_API_TOKEN'));
$phrase = "never forget tomorrow is a new day";
$td = "test-data";
$errors = 0;
function check($step, $json) {
global $errors;
$r = json_decode($json);
$code = $r->responseCode ?? '?';
echo ($code === 'SUCC' ? 'PASS' : 'FAIL') . ": $step ($code)\n";
if ($code !== 'SUCC') $errors++;
return $r;
}
$r = check("CreateUser", $vi->createUser());
$userId = $r->userId;
for ($i = 1; $i <= 3; $i++) {
check("VideoEnrollment$i", $vi->createVideoEnrollment($userId, "en-US", $phrase, "$td/videoEnrollmentA$i.mov"));
}
$r = check("VideoVerification", $vi->videoVerification($userId, "en-US", $phrase, "$td/videoVerificationA1.mov"));
echo " Voice: {$r->voiceConfidence}, Face: {$r->faceConfidence}\n";
check("DeleteEnrollments", $vi->deleteAllEnrollments($userId));
check("DeleteUser", $vi->deleteUser($userId));
if ($errors > 0) { echo "\n$errors FAILURES\n"; exit(1); }
echo "\nAll tests passed!\n";