Setup Voice Verification

Uploading Api details to matches enrolled user's audio files with target user's audio file

try {
        // Retrieve stored enrollment recordings from localStorage
        const storedRecordings = JSON.parse(localStorage.getItem('enrollRecordings_' + username) || '[]');
        if (storedRecordings.length < 3) {
          alert('Enrollment recordings not found.');
          document.body.removeChild(progressDialog);
          return;
        }

        // Convert the base64 recordings back to Blobs in .wav format
        const blobSourceOne = base64ToBlob(storedRecordings[0], 'audio/wav');
        const blobSourceTwo = base64ToBlob(storedRecordings[1], 'audio/wav');
        const blobSourceThree = base64ToBlob(storedRecordings[2], 'audio/wav');



        // For the verify recording, use the first audio blob recorded during this session.
        const verifyBlob = audioBlobs[0];

        // Create a FormData object and append your .wav files.
        const formData = new FormData();
        formData.append('sourceone', blobSourceOne, 'sourceone.wav');   // Input One in wav format
        formData.append('sourcetwo', blobSourceTwo, 'sourcetwo.wav'); // Input Two in wav format
        formData.append('sourcethree', blobSourceThree, 'sourcethree.wav'); // Input Three in wav format
        formData.append('target', verifyBlob, 'target.wav'); // Input Four in wav format


        // Call the API
        const response = await fetch("Your API", {
          method: "POST",
          body: formData
        });
        if (response.ok) {
          const responseBody = await response.text();
          alert('Upload successful: ' + responseBody);
        } else {
          throw new Error('Upload failed with status ' + response.status);
        }
      } catch (error) {
        alert('Error during upload: ' + error);
      }

Last updated