filiptronicek / ai100demos

Demos fro AI-10X training

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AI-10X demos

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.

Before you start

Where to put endpoint and key

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"

Speech

Demos using speech needs audio files. Some sample audio files are included. Information about supported audio format.

How to create audio samples

  • 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.

Limitation

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.

How to use

  • 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_ or Get-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.

Cognitive Services REST API playground

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.

REST API Test Console

Cleanup

  • Run cleanup.ps1 to delete resources in Azure
  • Delete the ai100demos folder

About

Demos fro AI-10X training


Languages

Language:Python 91.4%Language:PowerShell 5.9%Language:Shell 2.7%