> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 运行 Audio Analytics 容器

> 部署并运行 Audio Analytics 容器，实现设备端 ASR、文本翻译和 TTS。

Qualcomm 的 Audio Analytics 容器通过 REST 和 WebSocket API 提供语音识别（ASR）、文本翻译（T2T）和文本转语音（TTS）功能。所有模型完全在设备端的 Qualcomm NPU 上运行。

## 主要特性

* **一个容器三种服务**：通过单一 API 提供 ASR、文本到文本翻译和 TTS
* **NPU 加速**：Whisper、OpusMT、MeloTTS 和 PiperTTS 模型全部在 Qualcomm NPU 上运行，释放 CPU 用于其他任务
* **多语言**：三种服务均支持英语、西班牙语和中文；PiperTTS 还支持德语和意大利语
* **流式支持**：除了基于文件的批量转录外，还支持通过 WebSocket 进行实时转录
* **OpenAPI / Swagger UI**：交互式 API 文档位于 `http://<device-ip>:8085/docs`

## 支持的模型

| 服务  | 模型                                                  | 语言         | 采样率      |
| --- | --------------------------------------------------- | ---------- | -------- |
| ASR | `whisper-small-quantized`                           | 英语、西班牙语、中文 | 16000 Hz |
| 翻译  | `opus-en-es`、`opus-es-en`、`opus-en-zh`、`opus-zh-en` | 英语、西班牙语、中文 | 不适用      |
| TTS | `melo-tts-en`、`melo-tts-es`、`melo-tts-zh`           | 英语、西班牙语、中文 | 44100 Hz |
| TTS | `piper-tts-en`、`piper-tts-de`、`piper-tts-it`        | 英语、德语、意大利语 | 22050 Hz |

以上是当前支持的模型。查询 `/transcriptions/models`、`/translations/models` 和 `/tts/models` 可确认运行时加载了哪些模型。

## 设置

以下步骤假设您已完成设备设置（[IQ-9075 EVK](/zh/devices/iq9075-evk/set-up-the-device) 或 [IQ-8275 EVK](/zh/devices/iq8275-evk/set-up-the-device)）。设备设置完成后，请按照以下步骤部署并运行 Audio Analytics 容器。

<Steps>
  <Step title="安装所需软件包">
    通过 SSH 连接到您的设备并安装所需软件包：

    ```bash theme={null}
    sudo apt update
    sudo apt install curl unzip docker-compose
    ```
  </Step>

  <Step title="设置 Docker">
    ```bash theme={null}
    # Configure Docker group
    sudo groupadd docker
    sudo usermod -aG docker $USER
    newgrp docker
    ```
  </Step>

  <Step title="下载模型">
    创建模型目录结构，并从 QAI Hub 下载所有模型。

    <AccordionGroup>
      <Accordion title="IQ-9075 EVK">
        ```bash theme={null}
        mkdir -p ~/models/audio/asr ~/models/audio/tts ~/models/audio/translation
        cd ~/models

        # ASR — Whisper Small
        curl -L -o whisper_small_quantized.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/whisper_small_quantized/releases/v0.57.0/whisper_small_quantized-voice_ai-w8a16-qualcomm_qcs9075.zip
        unzip -q whisper_small_quantized.zip -d audio/asr && rm whisper_small_quantized.zip

        # TTS — MeloTTS (English, Spanish, Chinese)
        curl -L -o melotts_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/melotts_en/releases/v0.57.0/melotts_en-voice_ai-mixed_with_float-qualcomm_qcs9075.zip
        unzip -q melotts_en.zip -d audio/tts && rm melotts_en.zip

        curl -L -o melotts_es.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/melotts_es/releases/v0.57.0/melotts_es-voice_ai-mixed_with_float-qualcomm_qcs9075.zip
        unzip -q melotts_es.zip -d audio/tts && rm melotts_es.zip

        curl -L -o melotts_zh.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/melotts_zh/releases/v0.57.0/melotts_zh-voice_ai-mixed_with_float-qualcomm_qcs9075.zip
        unzip -q melotts_zh.zip -d audio/tts && rm melotts_zh.zip

        # TTS — PiperTTS (English, German, Italian)
        curl -L -o pipertts_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/pipertts_en/releases/v0.57.0/pipertts_en-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q pipertts_en.zip -d audio/tts && rm pipertts_en.zip

        curl -L -o pipertts_de.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/pipertts_de/releases/v0.57.0/pipertts_de-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q pipertts_de.zip -d audio/tts && rm pipertts_de.zip

        curl -L -o pipertts_it.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/pipertts_it/releases/v0.57.0/pipertts_it-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q pipertts_it.zip -d audio/tts && rm pipertts_it.zip

        # Translation — Opus (English ↔ Spanish, English ↔ Chinese)
        curl -L -o opus_mt_en_es.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_en_es/releases/v0.57.0/opus_mt_en_es-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q opus_mt_en_es.zip -d audio/translation && rm opus_mt_en_es.zip

        curl -L -o opus_mt_es_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_es_en/releases/v0.57.0/opus_mt_es_en-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q opus_mt_es_en.zip -d audio/translation && rm opus_mt_es_en.zip

        curl -L -o opus_mt_en_zh.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_en_zh/releases/v0.57.0/opus_mt_en_zh-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q opus_mt_en_zh.zip -d audio/translation && rm opus_mt_en_zh.zip

        curl -L -o opus_mt_zh_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_zh_en/releases/v0.57.0/opus_mt_zh_en-voice_ai-float-qualcomm_qcs9075.zip
        unzip -q opus_mt_zh_en.zip -d audio/translation && rm opus_mt_zh_en.zip
        ```
      </Accordion>

      <Accordion title="IQ-8275 EVK">
        ```bash theme={null}
        mkdir -p ~/models/audio/asr ~/models/audio/tts ~/models/audio/translation
        cd ~/models

        # ASR — Whisper Small
        curl -L -o whisper_small_quantized.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/whisper_small_quantized/releases/v0.57.0/whisper_small_quantized-voice_ai-w8a16-qualcomm_qcs8275.zip
        unzip -q whisper_small_quantized.zip -d audio/asr && rm whisper_small_quantized.zip

        # TTS — MeloTTS (English, Spanish, Chinese)
        curl -L -o melotts_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/melotts_en/releases/v0.57.0/melotts_en-voice_ai-mixed_with_float-qualcomm_qcs8275.zip
        unzip -q melotts_en.zip -d audio/tts && rm melotts_en.zip

        curl -L -o melotts_es.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/melotts_es/releases/v0.57.0/melotts_es-voice_ai-mixed_with_float-qualcomm_qcs8275.zip
        unzip -q melotts_es.zip -d audio/tts && rm melotts_es.zip

        curl -L -o melotts_zh.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/melotts_zh/releases/v0.57.0/melotts_zh-voice_ai-mixed_with_float-qualcomm_qcs8275.zip
        unzip -q melotts_zh.zip -d audio/tts && rm melotts_zh.zip

        # TTS — PiperTTS (English, German, Italian)
        curl -L -o pipertts_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/pipertts_en/releases/v0.57.0/pipertts_en-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q pipertts_en.zip -d audio/tts && rm pipertts_en.zip

        curl -L -o pipertts_de.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/pipertts_de/releases/v0.57.0/pipertts_de-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q pipertts_de.zip -d audio/tts && rm pipertts_de.zip

        curl -L -o pipertts_it.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/pipertts_it/releases/v0.57.0/pipertts_it-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q pipertts_it.zip -d audio/tts && rm pipertts_it.zip

        # Translation — Opus (English ↔ Spanish, English ↔ Chinese)
        curl -L -o opus_mt_en_es.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_en_es/releases/v0.57.0/opus_mt_en_es-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q opus_mt_en_es.zip -d audio/translation && rm opus_mt_en_es.zip

        curl -L -o opus_mt_es_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_es_en/releases/v0.57.0/opus_mt_es_en-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q opus_mt_es_en.zip -d audio/translation && rm opus_mt_es_en.zip

        curl -L -o opus_mt_en_zh.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_en_zh/releases/v0.57.0/opus_mt_en_zh-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q opus_mt_en_zh.zip -d audio/translation && rm opus_mt_en_zh.zip

        curl -L -o opus_mt_zh_en.zip \
          https://qaihub-public-assets.s3.us-west-2.amazonaws.com/qai-hub-models/models/opus_mt_zh_en/releases/v0.57.0/opus_mt_zh_en-voice_ai-float-qualcomm_qcs8275.zip
        unzip -q opus_mt_zh_en.zip -d audio/translation && rm opus_mt_zh_en.zip
        ```
      </Accordion>
    </AccordionGroup>

    您的模型目录现在应该如下所示：

    ```
    ~/models/audio/
    ├── asr/          ← whisper_small_quantized
    ├── tts/          ← melotts_en, melotts_es, melotts_zh, pipertts_en, pipertts_de, pipertts_it
    └── translation/  ← opus_mt_en_es, opus_mt_es_en, opus_mt_en_zh, opus_mt_zh_en
    ```
  </Step>

  <Step title="获取 Docker Compose 文件">
    从 [CodeLinaro audio-analytics deploy 目录](https://git.codelinaro.org/clo/iot-solutions-microservices/audio-analytics/-/tree/main/deploy)下载适用于您设备的 Docker Compose 文件。

    <AccordionGroup>
      <Accordion title="IQ-9075 EVK">
        **方式 A — 直接在设备上下载：**

        ```bash theme={null}
        curl -L -o docker-compose-qcs9100.yml \
          https://git.codelinaro.org/clo/iot-solutions-microservices/audio-analytics/-/raw/main/deploy/docker-compose-qcs9100.yml
        ```

        **方式 B — 在本地下载后复制到设备：**

        ```bash theme={null}
        scp docker-compose-qcs9100.yml ubuntu@<device-ip>:~/
        ```
      </Accordion>

      <Accordion title="IQ-8275 EVK">
        **方式 A — 直接在设备上下载：**

        ```bash theme={null}
        curl -L -o docker-compose-qcs8300.yml \
          https://git.codelinaro.org/clo/iot-solutions-microservices/audio-analytics/-/raw/main/deploy/docker-compose-qcs8300.yml
        ```

        **方式 B — 在本地下载后复制到设备：**

        ```bash theme={null}
        scp docker-compose-qcs8300.yml ubuntu@<device-ip>:~/
        ```
      </Accordion>
    </AccordionGroup>

    <Note>后续步骤使用 `docker-compose-qcs9100.yml`。如果您使用的是 IQ-8275 EVK，请在每条命令中替换为 `docker-compose-qcs8300.yml`。</Note>
  </Step>

  <Step title="配置容器">
    打开 Docker Compose 文件，并根据需要调整以下环境变量：

    * **`MODELS_DIR`**：容器内所有模型的基础路径（默认：`/mnt/work/models`）
    * **`SESSION_TIMEOUT_S`**：ASR 流式会话自动关闭前的不活动秒数（默认：`30`）
    * **`LOG_LEVEL`**：`10`=DEBUG、`20`=INFO、`30`=WARNING、`40`=ERROR（默认：`20`）

    在 `volumes:` 下：

    * **模型路径**：默认将主机上的 `~/models/audio` 映射到容器中的 `/mnt/work/models`。如果您将模型放在其他位置，请更新卷挂载的左侧：

    ```yaml theme={null}
    volumes:
      - ~/models/audio:/mnt/work/models:ro
    ```

    <Warning>确保卷挂载指向您的模型目录，并且该目录可被容器读取。如果模型加载失败，请使用 `ls -la ~/models/audio` 检查目录权限。</Warning>
  </Step>

  <Step title="启动容器">
    如果容器镜像尚未存在，Docker Compose 文件会自动拉取。

    ```bash theme={null}
    docker compose -f docker-compose-qcs9100.yml up -d
    ```

    验证容器正在运行：

    ```bash theme={null}
    docker ps | grep audio-analytics
    ```
  </Step>

  <Step title="验证服务正在运行">
    就绪后，检查健康检查端点：

    ```bash theme={null}
    curl http://localhost:8085/audio-analytics/v1/api/health
    ```

    预期响应：

    ```json theme={null}
    { "status": "ok", "uptime": 12345, "active_sessions": 0, "version": "1.0.0" }
    ```

    您还可以确认加载了哪些模型：

    ```bash theme={null}
    curl http://localhost:8085/audio-analytics/v1/api/transcriptions/models
    curl http://localhost:8085/audio-analytics/v1/api/translations/models
    curl http://localhost:8085/audio-analytics/v1/api/tts/models
    ```
  </Step>

  <Step title="测试各项服务">
    为三种服务分别运行一次快速冒烟测试。

    **ASR — 转录音频：**

    ```bash theme={null}
    curl -X POST http://localhost:8085/audio-analytics/v1/api/transcriptions/create \
      -F 'file=@audio.wav' \
      -F 'model=whisper-small-quantized' \
      -F 'language=en' \
      -F 'stream=false'
    ```

    预期响应：

    ```json theme={null}
    { "text": "Your transcribed text here.", "language": "en", "type": "transcript.text.done" }
    ```

    **翻译 — 翻译文本：**

    ```bash theme={null}
    curl -X POST http://localhost:8085/audio-analytics/v1/api/translations/translate \
      -H 'Content-Type: application/json' \
      -d '{"text": ["Hello world"], "model": "opus-en-es", "source_language": "en", "target_language": "es"}'
    ```

    预期响应：

    ```json theme={null}
    { "translations": [{ "translated_text": "Hola mundo", "source_language": "en", "target_language": "es" }] }
    ```

    **TTS — 合成语音：**

    ```bash theme={null}
    curl -X POST http://localhost:8085/audio-analytics/v1/api/tts/synthesize \
    -H 'Content-Type: application/json' \
    -d '{"text": "Hello, how are you today?", "model": "melo-tts-en", "language": "en", "sample_rate": 44100}' \
    --output speech.pcm
    ```
  </Step>

  <Step title="停止容器">
    完成后：

    ```bash theme={null}
    docker compose -f docker-compose-qcs9100.yml down
    ```
  </Step>
</Steps>

## 查看日志

所有容器输出均可通过 `docker logs` 查看。没有单独的日志文件。

```bash theme={null}
# Stream all logs
docker logs audio-analytics -f -t
```

要调整日志详细程度，请在 Docker Compose 文件中设置 `LOG_LEVEL` 并重启容器：

| 值    | 级别       |
| ---- | -------- |
| `10` | DEBUG    |
| `20` | INFO（默认） |
| `30` | WARNING  |
| `40` | ERROR    |

## 后续步骤

<CardGroup cols={3}>
  <Card title="语音识别" icon="microphone" href="/zh/ai-workflows/asr-container">
    基于文件和实时流式的转录
  </Card>

  <Card title="文本转语音" icon="volume-high" href="/zh/ai-workflows/tts-container">
    以多种语言合成自然语音
  </Card>

  <Card title="语言翻译" icon="language" href="/zh/ai-workflows/language-translation">
    在设备端进行跨语言文本翻译
  </Card>
</CardGroup>
