Speaker Recognition is the process of analyzing unique voice characteristics to identify and verify individuals, enabling applications such as voice authentication, speaker-based personalization, and speaker spotting.

A major challenge for many Speaker Recognition applications is the high latency of cloud-based services, which leads to poor user experience. Fortunately, Picovoice's Eagle Speaker Recognition provides on-device Speaker Recognition, effectively bypassing the issues posed by cloud usage without sacrificing accuracy.

In just a few lines of code, you can start performing Speaker Recognition with a microphone using the Eagle Speaker Recognition Web SDK. Let’s get started!

Install Eagle Speaker Recognition Web SDK

Install the Eagle Speaker Recognition Web SDK using npm:

Sign up for Picovoice Console

Next, create a Picovoice Console account, and copy your AccessKey from the main dashboard. Creating an account is free, and no credit card is required!

Usage

Eagle Speaker Recognition Model

Add the Eagle Speaker Recognition model to the project by:

  • Either copying the model file to the project's public directory:

(or)

  • Create a base64 string of the model using the pvbase64 script included in the package:

Create an object containing the Eagle model options:

Speaker Enrollment

Initialize an Eagle Profiler with the eagleModel variable containing the model options:

EagleWorker uses web workers to process audio data. Web workers might not be supported (i.e. Firefox private mode). In this case, use Eagle instead, which uses the main thread to process audio data.

Enroll speakers

The .enroll() function takes in frames of audio and provides feedback on the audio quality and Enrollment percentage. Use the percentage value to determine when Enrollment is completed and another speaker can be enrolled:

Once Enrollment reaches 100%, export the speaker profile to use in the next step, Speaker Recognition:

Profiles can be made for additional users by calling the .reset() function on the EagleProfiler, and repeating the .enroll() step.

Once profiles have been created for all speakers, make sure to clean up used resources:

Speaker Recognition

Initialize an Eagle Profiler with the same eagleModel described above as well as the speaker profile created by the Speaker Enrollment step:

If you have multiple speaker profiles created, simply pass in an array of your speaker profiles instead.

To perform speaker recognition, pass audio frames into the eagle.process() function, and it will return the speaker scores:

When finished, make sure to clean up used resources:

Putting It All Together

All that is left is to wire up the audio recording. This example uses WebVoiceProcessor to record audio.

Install web-voice-processor using npm:

The following code snippet records audio and performs speaker recognition on the recorded audio:

Next Steps

For a complete working project, take a look at the Eagle Speaker Recognition Web Demo. You can also view the Eagle Speaker Recognition Web API docs for details on the package.