|
| 1 | +# Deploying ASR Service |
| 2 | + |
| 3 | +This document provides a comprehensive guide to deploying the ASR microservice pipeline with the Paraformer model on Intel platforms. |
| 4 | + |
| 5 | +**Note:** This is an alternative of the [Whisper ASR service](./README.md). The Paraformer model supports both English and Mandarin audio input, and empirically it shows better performance in Mandarin than English. |
| 6 | + |
| 7 | +## Table of contents |
| 8 | + |
| 9 | +- [🚀 1. Quick Start with Docker Compose](#-1-quick-start-with-docker-compose): The recommended method for a fast and easy setup. |
| 10 | +- [🚀 2. Manual Step-by-Step Deployment (Advanced)](#-2-manual-step-by-step-deployment-advanced): For users who want to build and run each container individually. |
| 11 | +- [🚀 3. Start Microservice with Python](#-3-start-microservice-with-python): For users who prefer to run the ASR microservice directly with Python scripts. |
| 12 | + |
| 13 | +## 🚀 1. Quick Start with Docker Compose |
| 14 | + |
| 15 | +This method uses Docker Compose to start all necessary services with a single command. It is the fastest and easiest way to get the service running. |
| 16 | + |
| 17 | +### 1.1. Access the Code |
| 18 | + |
| 19 | +Clone the repository and navigate to the deployment directory: |
| 20 | + |
| 21 | +```bash |
| 22 | +git clone https://github.com/opea-project/GenAIComps.git |
| 23 | +cd GenAIComps/comps/asr/deployment/docker_compose |
| 24 | +``` |
| 25 | + |
| 26 | +### 1.2. Deploy the Service |
| 27 | + |
| 28 | +Choose the command corresponding to your target platform. |
| 29 | + |
| 30 | +```bash |
| 31 | +export ip_address=$(hostname -I | awk '{print $1}') |
| 32 | +export ASR_ENDPOINT=http://$ip_address:7066 |
| 33 | +export no_proxy=localhost,$no_proxy |
| 34 | +``` |
| 35 | + |
| 36 | +- **For Intel® Core® CPU:** |
| 37 | + ```bash |
| 38 | + docker compose -f ../docker_compose/compose.yaml up funasr-paraformer-service asr-funasr-paraformer -d |
| 39 | + ``` |
| 40 | + **Note:** it might take some time for `funasr-paraformer-service` to get ready, depending on the model download time in your network environment. If it fails to start with error message `dependency failed to start: container funasr-paraformer-service is unhealthy`, try increasing healthcheck retries in `GenAIComps/comps/third_parties/funasr/deployment/docker_compose/compose.yaml` |
| 41 | + |
| 42 | +### 1.3. Validate the Service |
| 43 | + |
| 44 | +Once the containers are running, you can validate the service. **Note:** Run these commands from the root of the `GenAIComps` repository. |
| 45 | + |
| 46 | +```bash |
| 47 | +# Test |
| 48 | +wget https://github.com/intel/intel-extension-for-transformers/raw/main/intel_extension_for_transformers/neural_chat/assets/audio/sample.wav |
| 49 | +curl http://localhost:9099/v1/audio/transcriptions \ |
| 50 | + -H "Content-Type: multipart/form-data" \ |
| 51 | + -F file="@./sample.wav" \ |
| 52 | + -F model="paraformer-zh" |
| 53 | +``` |
| 54 | + |
| 55 | +### 1.4. Clean Up the Deployment |
| 56 | + |
| 57 | +To stop and remove the containers, run the following command from the `comps/asr/deployment/docker_compose` directory: |
| 58 | + |
| 59 | +```bash |
| 60 | +docker compose down |
| 61 | +``` |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## 🚀 2. Manual Step-by-Step Deployment (Advanced) |
| 66 | + |
| 67 | +This section provides detailed instructions for building the Docker images and running each microservice container individually. |
| 68 | + |
| 69 | +### 2.1. Clone the Repository |
| 70 | + |
| 71 | +If you haven't already, clone the repository and navigate to the root directory: |
| 72 | + |
| 73 | +```bash |
| 74 | +git clone https://github.com/opea-project/GenAIComps.git |
| 75 | +cd GenAIComps |
| 76 | +``` |
| 77 | + |
| 78 | +### 2.2. Build the Docker Images |
| 79 | + |
| 80 | +#### 2.2.1. Build FunASR Paraformer Server Image |
| 81 | + |
| 82 | +- **For Intel® Core® CPU:** |
| 83 | + ```bash |
| 84 | + docker build -t opea/funasr-paraformer:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/third_parties/funasr/src/Dockerfile . |
| 85 | + ``` |
| 86 | + |
| 87 | +#### 2.2.2. Build ASR Service Image |
| 88 | + |
| 89 | +```bash |
| 90 | +docker build -t opea/asr:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/asr/src/Dockerfile . |
| 91 | +``` |
| 92 | + |
| 93 | +### 2.3 Start FunASR Paraformer and ASR Service |
| 94 | + |
| 95 | +#### 2.3.1 Start FunASR Paraformer Server |
| 96 | + |
| 97 | +- Core CPU |
| 98 | + |
| 99 | +```bash |
| 100 | +docker run -p 7066:7066 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy opea/funasr-paraformer:latest |
| 101 | +``` |
| 102 | + |
| 103 | +#### 2.3.2 Start ASR service |
| 104 | + |
| 105 | +```bash |
| 106 | +ip_address=$(hostname -I | awk '{print $1}') |
| 107 | + |
| 108 | +docker run -d -p 9099:9099 --ipc=host -e http_proxy=$http_proxy -e https_proxy=$https_proxy -e no_proxy=$no_proxy -e ASR_ENDPOINT=http://$ip_address:7066 opea/asr:latest |
| 109 | +``` |
| 110 | + |
| 111 | +### 2.4 Validate the Service |
| 112 | + |
| 113 | +After starting both containers, test the asr service endpoint. Make sure you are in the root directory of the `GenAIComps` repository. |
| 114 | + |
| 115 | +```bash |
| 116 | +# Use curl or python |
| 117 | + |
| 118 | +# curl |
| 119 | +wget https://github.com/intel/intel-extension-for-transformers/raw/main/intel_extension_for_transformers/neural_chat/assets/audio/sample.wav |
| 120 | +curl http://localhost:9099/v1/audio/transcriptions \ |
| 121 | + -H "Content-Type: multipart/form-data" \ |
| 122 | + -F file="@./sample.wav" \ |
| 123 | + -F model="paraformer-zh" |
| 124 | + |
| 125 | +# python |
| 126 | +python check_asr_server.py |
| 127 | +``` |
| 128 | + |
| 129 | +### 2.6. Clean Up the Deployment |
| 130 | + |
| 131 | +To stop and remove the containers you started manually, use the `docker stop` and `docker rm` commands. |
| 132 | + |
| 133 | +- **For Intel® Core® CPU:** |
| 134 | + ```bash |
| 135 | + docker stop funasr-paraformer-service asr-funasr-paraformer-service |
| 136 | + docker rm funasr-paraformer-service asr-funasr-paraformer-service |
| 137 | + ``` |
| 138 | + |
| 139 | +## 🚀 3. Start Microservice with Python |
| 140 | + |
| 141 | +To start the ASR microservice with Python, you need to first install python packages. |
| 142 | + |
| 143 | +### 3.1 Install Requirements |
| 144 | + |
| 145 | +```bash |
| 146 | +pip install -r requirements-cpu.txt |
| 147 | +``` |
| 148 | + |
| 149 | +### 3.2 Start FunASR Paraformer Service/Test |
| 150 | + |
| 151 | +- Core CPU |
| 152 | + |
| 153 | +```bash |
| 154 | +cd comps/third_parties/funasr/src |
| 155 | +nohup python funasr_server.py --device=cpu & |
| 156 | +python check_funasr_server.py |
| 157 | +``` |
| 158 | + |
| 159 | +Note: please make sure that port 7066 is not occupied by other services. Otherwise, use the command `npx kill-port 7066` to free the port. |
| 160 | + |
| 161 | +### 3.3 Start ASR Service/Test |
| 162 | + |
| 163 | +```bash |
| 164 | +cd ../../.. |
| 165 | +python opea_asr_microservice.py |
| 166 | +python check_asr_server.py |
| 167 | +``` |
0 commit comments