This repository contains an Express.js application that leverages the Microsoft Cognitive Services Speech SDK to perform vocal recognition. This allows you to transcribe spoken language from audio data using Azure Cognitive Services.
Before you can run this application, you'll need to set up the following:
-
Azure Cognitive Services Subscription: You'll need to obtain subscription keys and region information to use the Speech SDK. You can obtain these by signing up for the Azure Cognitive Services Speech SDK and creating a subscription.
-
Environment Variables: Create a
.env
file in the project root directory with the following environment variables:KEY_AZURE=<Your Azure Cognitive Services Subscription Key> REGION=<Your Azure Region> PORT=<Port for the Express.js server, optional>
Replace
<Your Azure Cognitive Services Subscription Key>
and<Your Azure Region>
with your actual subscription key and region.
-
Clone this repository to your local machine:
-
Navigate to the project directory:
-
Install the project dependencies:
npm install
-
Start the Express.js server:
npm start
The server will start on the port specified in your .env
file or on port 5000 by default.
To use the vocal recognition service, you can make a POST request to the your_url/vocal_recognition
endpoint with the following JSON payload:
{
"language": "en-US", // Specify the language for recognition
"audio_data": "base64-encoded-audio-data"
}
Replace "en-US"
with the desired recognition language code, and "base64-encoded-audio-data"
with your audio data encoded in base64.
example of other language format :
- arab: "ar-MA", //Maroc
- german: "de-DE",
- english: "en-GB", //Royaume-uni
- spanish: "es-ES",
- finnish: "fi-FI",
- french: "fr-FR",
- italian: "it-IT",
- dutch: "nl-NL",
- portuguese: "pt-PT",
- ukrainian: "uk-UA",
The server will respond with the recognized text if successful.
example :
{
"recognized_word":"your words"
}
The application handles various error scenarios, such as missing parameters, invalid base64 data, recognition errors, and internal server errors. Ensure that you handle errors gracefully in your own use cases.
Feel free to contribute to this project by opening issues or creating pull requests. Contributions are welcome!
Make sure to replace <Your Azure Cognitive Services Subscription Key>
and <Your Azure Region>
with your actual Azure subscription key and region in the .env
setup section. You can also customize the README further to include additional information about the project, dependencies, and any specific instructions for running or deploying it.