How to Build from Source#
Build the Audio Analyzer microservice from source to customize, debug, or extend its functionality. In this guide, you will:
Set up your development environment.
Compile the source code and resolve dependencies.
Generate a runnable build for local testing or deployment.
This guide is ideal for developers who want to work directly with the source code.
Prerequisites#
Before you begin, ensure the following:
System Requirements: Verify your system meets the minimum requirements.
This guide assumes basic familiarity with Git commands, Python virtual environments, and terminal usage. If you are new to these concepts, see:
Follow all the steps provided in get started documentation with respect to environment variables configuration, setting up of storage backends and model selection.
Steps to Build#
Following options are provided to build the microservice.
Build and Run using Docker Script#
Clone the repository:
# Clone the latest on mainline git clone https://github.com/open-edge-platform/edge-ai-libraries.git edge-ai-libraries # Alternatively, Clone a specific release branch git clone https://github.com/open-edge-platform/edge-ai-libraries.git edge-ai-libraries -b <release-tag>
Default storage backend used in the Docker script based setup is
minio. We need to set following required environment variables for Minio on shell:# MinIO credentials (required) export MINIO_ACCESS_KEY=<your-minio-username> export MINIO_SECRET_KEY=<your-minio-password>
NOTE : To override the default storage backend, see setup the storage backends.
The Docker setup will build the image if not already present on the machine. We can optionally set a registry URL and tag, if we wish to push this image to any repository. If not set, default image will be built as
audio-analyzer:latest.# Optional: Set registry URL and project name for docker image naming export REGISTRY_URL=<your-registry-url> export PROJECT_NAME=<your-project-name> export TAG=<your-tag>
If
REGISTRY_URLis provided, the final image name will be:${REGISTRY_URL}${PROJECT_NAME}/audio-analyzer:${TAG}
IfREGISTRY_URLis not provided, the image name will be:${PROJECT_NAME}/audio-analyzer:${TAG}Set the required environment variables:
# (Required) Comma-separated list of models to download export ENABLED_WHISPER_MODELS=small.en,tiny.en,medium.en
(OPTIONAL) You can customize the setup with these additional environment variables:
# Set a default model to use, if one is not provided explicitly. Should be one of the ENABLED_WHISPER_MODELS export DEFAULT_WHISPER_MODEL=tiny.en # Device to use: cpu, gpu, or auto export DEFAULT_DEVICE=cpu export USE_FP16=true # Storage backend: minio or local export STORAGE_BACKEND=minio export MAX_FILE_SIZE=314572800
Run the setup script to build and bring up production version of application. This also brings up Minio Server container (if default minio storage backend is used):
cd edge-ai-libraries/microservices/audio-analyzer chmod +x ./setup_docker.sh ./setup_docker.sh
Docker Setup Options#
The setup_docker.sh script when run without any parameters builds and runs the production docker images. It additionally supports the following options:
Options:
--dev Build and run development environment
--build Only build production Docker image
--build-dev Only build development Docker image
--down Stop and remove all containers, networks,
and volumes
-h, --help Show this help message
Examples:
Production setup:
./setup_docker.shDevelopment setup:
./setup_docker.sh --devBuild production image only:
./setup_docker.sh --buildBuild development image only:
./setup_docker.sh --build-devStop and remove all containers:
./setup_docker.sh --down
The development environment provides:
Hot-reloading of code changes
Mounting of local code directory into container
Debug logging enabled
The production environment uses:
Gunicorn with multiple worker processes
Optimized container without development dependencies
No source code mounting (code is copied at build time)
Setup and run on host using Setup Script#
Clone the repository:
# Clone the latest on mainline git clone https://github.com/open-edge-platform/edge-ai-libraries.git edge-ai-libraries # Alternatively, Clone a specific release branch git clone https://github.com/open-edge-platform/edge-ai-libraries.git edge-ai-libraries -b <release-tag>
Run the setup script with desired options:
cd edge-ai-libraries/microservices/audio-analyzer chmod +x ./setup_host.sh ./setup_host.sh
Available options:
--debug,-d: Enable debug mode--reload,-r: Enable auto-reload on code changes
The setup script will:
Install all required system dependencies
Create directories for model storage. For host setup using script, only storage backend available is local filesystem.
Install Poetry and project dependencies
Start the Audio Analyzer service
Validation#
Verify Build Success:
Check the logs. Look for confirmation messages indicating the microservice started successfully.
Troubleshooting#
Supporting Resources#
Overview