Author: Manuel Lemos
Last month viewers: 72
Categories: PHP Tutorials, Notable Packages
A Web application written in PHP can take an audio sample uploaded the Web server and use a voice recognition API like for instance Microsoft Azure Cognitive Services API to register the audio sample and associate it to a given person.
The same API can analyze a new audio sample with a user voice to tell if it is of a person that the recognition system is able to already identify as being of the real person with that voice.
This article and the video tutorial that is presented here gives more details of how to implement this approach in practice in PHP.
If you want to know more about what is voice recognition, why it is useful for Web based applications, and how you can use it in practice in PHP, keep watching this short tutorial video or continue reading the article below.
What is Voice Recognition?
A voice is a unique characteristic of each human being.
The voice recognition process consists in analyzing an audio sample with a human voice.
Therefore this process can be used identify different people that may be talking in the analyzed audio sample.
Why You May Need to Use Voice Recognition in Your Applications?
Over the years, the security of the computer based systems has been a growing concern among many institutions that need to identify the different people that may be able to access those systems.
Since Internet connections may be used to access those systems, often the systems may be accessible by people that do not have authorization to access them.
To increase the security of systems, modern approaches use multi-factor based authentication methods to verify if an authorized user is accessing a system.
This means that not only a password based method can be used, but other factors can be used together to confirm that an user is really a person authorized to access a system.
Nowadays, biometric methods are being used to authenticate an authorized person. This means that systems can recognize aspects related with the human body of the person, like his fingerprint, eye iris, face image and voice audio.
Therefore voice audio recognition can be used in conjunction with other methods to authenticate users to implement stronger security methods based in the multi-factor authentication approach.
How Can You Use Voice Recognition in PHP?
The Cognitive PHP Voice Recognition package can perform all the steps necessary to implement a PHP based solution for voice recognition.
Using the Cognitive PHP Voice Recognition package, this process can be implemented in 4 steps. Lets take a look at each of those steps.
Configure the Cognitive PHP Voice Recognition package
The configuration of this class is done using environment variable files.
In your project root directory create a text file named
.envto assign the values of some configuration variables like this:
SPEECH_KEY=[your subscription key to access the Microsoft Azure Speaker Recognition API here]
To get your API subscription key you need to follow the instructions in the page about the Subscriptions in Azure API Management.
Voice Profile Creation
This step consists if preparing the Microsoft Azure Speaker Recognition system to recognize individual voices that you want your application to recognize.
First you need to create an object of the class
Speech. Then you need to create a voice verification profile.
For simplicity, the code for verifying the success of the API calls that are invoked was omitted.
$speaker = new Speech();
$verification_id = $speaker->createVerificationProfile()
Then you need to pass audio files with the voice of the people you want the Microsoft Azure Speaker Recognition system to recognize.
You can do this by passing a audio sample file in WAV format to the Microsoft Azure Speaker Recognition API.
You need to pass as parameter the identifier of the voice profile that was previously created.
If the person voice audio sample that you have is not in the WAV format, you may need to convert it like this.
$original_audio_file_name = 'voice.mpg';
$wav_audio_file_name = $speaker->convertAudio( $original_audio_file_name );
The conversion process requires that you have the FFMPEG program installed in your environment on which you are running PHP.
Once the Microsoft Azure Speaker Recognition system has been trained to recognize the voices of the people you want, you can request it to identify a voice in a new audio sample like this:
$wav_audio_file_name = 'new_audio_sample.wav';
$result = $speaker->verifySpeaker( $wav_audio_file_name, $verification_id);
About the Cognitive PHP Voice Recognition Package
The basic purpose is: Recognize voices in audio with Microsoft Azure API
Here follows in more detail what it does:
This package can recognize voices in audio with Microsoft Azure API.
It can send HTTP requests to the Web server of the Microsoft Azure Cognitive Services API to perform operations to help verifying people's voices in audio samples. Currently it can:
- Create an audio verification profile
- Send an audio sample to train the system to recognize the people in that are speaking
- Verify the person that is speaking in a audio sample
- Convert audio samples to the WAV format, so those can be used by the Microsoft Azure Speak Recognition system
This package was considered notable for implementing its benefits in a way that is worth noticing.
Notable PHP packages can be often considered innovative. If this package is also innovative, it can be nominated to the PHP Innovation Award and the author may win prizes and recognition for sharing innovative packages.
If you also developed your own notable or innovative packages consider sharing them, so you can also earn more visibility for your package as well nice prizes.
One nice prize that many PHP developers want and you may like is the PHP elePHPant mascot plush.
You need to be a registered user or login to post a comment
Login Immediately with your account on:
No comments were submitted yet.