Demos for AI-10X training and certification. It can be used by a trainer or by attendees as homework. The goal is to understand how to call and use REST API for Cognitive Services.
- Become familiar with Azure Cloud Shell.
- Become familiar with Az.CognitiveServices PowerShell module.
- Become familiar with Environment Variables.
- Become familiar with Cognitive Services REST API.
- Read comments in code.
Service endpoint and key you need to add to environment variable. Another option is to create .env file and add it to this file. Example of .env file:
CV_ENDPOINT="https://xxxxxxxxxxxxx.cognitiveservices.azure.com/"
CV_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
CV_LOCATION="xxxxxxxx"
Demos using speech needs audio files. Some sample audio files are included. Information about supported audio format.
- Record audio sample using Windows 10 Voice Recorder. It produces .m4a audio file.
- Search for .m4a to .wav converter online.
- Convert .m4a to .wav file using an online tool.
- Rename file to message-LANGUAGE_CODE.wav. For example
message-cs-CZ.wav
. - Copy audio file to speech_translator/ folder.
Python code using a microphone and a speaker doesn't work in Azure Cloud Shell. You need to run that locally. All Azure Cloud Shell unsupported demos are in the speech_translator/local_pc_folder folder.
- Login to Azure Cloud Shell.
- Clone this repository.
git clone https://github.com/bechynsky/ai100demos.git
- Install Python libraries.
pip install azure-cognitiveservices-speech
- Goto
ai100demos
folder. - Run
code .
to open VS Code to see the code. - Run new_cognitiveservices.ps1.
- All information like endpoint and service key is stored in Environment variables.
- Check environment variables we create
printenv | grep CV_
orGet-ChildItem env:* | Where-Object {$_.Name -like 'CV_*'}
. - It is not persistent and information is lost after Azure Cloud Shell restarts.
- Copy output of the script for future reference.
If you want to change calls to REST API you can test it first.
- Open API Testing Console
- Use search on the top right to find an API.
- Choose the API you are looking for.
- Choose a method you want to test on the left (1) and then click your region (2).
- Now you can create a REST API Call and test it.
- Run
cleanup.ps1
to delete resources in Azure - Delete the
ai100demos
folder