function enrollVoice()

in website-creator/js/voiceid.js [114:136]


function enrollVoice() {
    $('#voice-id-prompt').text('Please wait while we enroll the customer...');
    if (typeof agent === "undefined") {
        agent = new connect.Agent();
    }
    let agentConn = agent.getContacts()[0].getConnections()[0];
    $('#loading-image').css('display', 'inline-block');
    agentConn.enrollSpeakerInVoiceId()
        .then((response) => {
            $('#voice-id-prompt').text(response.Session.EnrollmentRequestDetails.Status);
            $('#loading-image').css('display', 'none');
            if (response.Session.EnrollmentRequestDetails.Status === 'COMPLETED') {
                $('#register-voice-id').prop('disabled', true).css('opacity', 0.5).css('cursor', 'default');
                $('#opt-out').prop('disabled', false).css('opacity', 1).css('cursor', 'pointer');
                $('#voice-id-prompt').text('ENROLLED!');
            }
        })
        .catch((error) => {
            console.log(error);
            $('#voice-id-prompt').text('enrollSpeakerInVoiceId failed');
            $('#loading-image').css('display', 'none');
        });
}