This sample demonstrates the usage of Azure Voice Live API with avatar.
- Docker installed on your machine. You can download and install Docker from here.
- An active Azure account. If you don't have an Azure account, you can create a account here.
- A Microsoft Foundry resource created in one of the supported regions. For more information about region availability, see the voice live overview documentation.
The avatar feature is currently available in the following service regions: Southeast Asia, North Europe, West Europe, Sweden Central, South Central US, East US 2, and West US 2.
To run the sample, you need to build it into a Docker image. Navigate to the folder containing this README.md document (make sure you are inside the right directory):
# Windows (PowerShell/Command Prompt)
cd .\javascript\voice-live-avatar\# macOS/Linux (Terminal)
cd ./javascript/voice-live-avatar/Run below command to build the Docker image:
docker build -t voice-live-avatar .This command will create a Docker image named voice-live-avatar.
To start the sample, use the following command:
docker run --rm -p 3000:3000 voice-live-avatarThen open your web browser and navigate to http://localhost:3000 to access the sample.
-
Step 1: Under the
Connection Settingssection, fillAzure AI Services EndpointandSubscription Key, which can be obtained from theKeys and Endpointtab in your Azure AI Services resource. The endpoint can be the regional endpoint (e.g.,https://<region>.api.cognitive.microsoft.com/) or a custom domain endpoint (e.g.,https://<custom-domain>.cognitiveservices.azure.com/). -
Step 2: Under
Conversation Settingssection, configure the avatar:- Enable Avatar: Toggle the
Avatarswitch to enable the avatar feature. - Avatar Type: By default, a prebuilt avatar is used. Select a character from the
Avatardropdown list.- To use a photo avatar, toggle the
Use Photo Avatarswitch and select a prebuilt photo avatar character from the dropdown list. - To use a custom avatar, toggle the
Use Custom Avatarswitch and enter the character name in theCharacterfield.
- To use a photo avatar, toggle the
- Avatar Output Mode: Choose between
WebRTC(default, real-time streaming) andWebSocket(streams video data over the WebSocket connection). - Avatar Background Image URL (optional): Enter a URL to set a custom background image for the avatar.
- Scene Settings (photo avatar only): When using a photo avatar, adjust scene parameters such as
Zoom,Position X/Y,Rotation X/Y/Z, andAmplitude. These settings can also be adjusted live after connecting.
- Enable Avatar: Toggle the
-
Step 3: Click
Connectbutton to start the conversation. Once connected, you should see the avatar appearing on the page, and you can clickTurn on microphoneand start talking with the avatar with speech. -
Step 4: On top of the page, you can toggle the
Developer modeswitch to enable developer mode, which will show chat history in text and additional logs useful for debugging.
This sample can be deployed to cloud for global access. The recommended hosting platform is Azure Container Apps. Here are the steps to deploy this sample to Azure Container Apps:
-
Step 1: Push the Docker image to a container registry, such as Azure Container Registry. You can use the following command to push the image to Azure Container Registry:
docker tag voice-live-avatar <your-registry-name>.azurecr.io/voice-live-avatar:latest docker push <your-registry-name>.azurecr.io/voice-live-avatar:latest
-
Step 2: Create an
Azure Container Appand deploy the Docker image built from above steps, following Deploy from an existing container image. Make sure to set the environment variables as described in the previous sections, such asSPEECH_REGION,SPEECH_KEY, etc. -
Step 3: Once the
Azure Container Appis created, you can access the sample by navigating to the URL of theAzure Container Appin your browser.