build SenseVoice-Small ASR docker 镜像

创建日期: 2025-07-25 17:09 | 作者: 风波 | 浏览次数: 23 | 分类: AI

官方地址:https://www.modelscope.cn/models/iic/SenseVoiceSmall/summary

1. Dockerfile

FROM ubuntu:24.04

ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/*
RUN apt-get update --allow-releaseinfo-change

RUN apt install software-properties-common -y

RUN add-apt-repository ppa:deadsnakes/ppa -y

RUN apt install python3.10 python3.10-venv python3.10-dev -y

RUN python3.10 -m venv /opt/venv

ENV VIRTUAL_ENV=/opt/venv
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

RUN apt install -y libgl1

RUN apt install -y libgl1 libglib2.0-0 libsm6 libxext6 libxrender1

RUN pip install --upgrade pip setuptools wheel

RUN pip install modelscope -i https://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

RUN pip install onnxruntime -i https://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

RUN pip install funasr -i https://pypi.tuna.tsinghua.edu.cn/simple/

RUN pip install addict datasets==2.16.0 pyarrow==20.0.0 -i https://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

RUN pip install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 -i https://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

RUN pip install simplejson sortedcontainers -i https://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

RUN apt install libgomp1 -y

RUN apt install ffmpeg -y

RUN pip install numpy==1.26.4 -i https://mirrors.aliyun.com/pypi/simple/  --trusted-host mirrors.aliyun.com

COPY ./SenseVoiceSmall /opt/modelscope/hub/models/iic/SenseVoiceSmall

其中 SenseVoiceSmall 目录是通过下面代码下载的

from modelscope import snapshot_download
model_dir = snapshot_download('iic/SenseVoiceSmall')
print(model_dir)

docker-compose.yml

services:
  sensevoice-small:
    build:
      context: docker
      dockerfile: ./Dockerfile
    image: sensevoice:v1

3. 测试代码

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks
import sys

inference_pipeline = pipeline(
    task=Tasks.auto_speech_recognition,
    model='/opt/modelscope/hub/models/iic/SenseVoiceSmall',
    model_revision="master",
    device="cuda:0",)

for filename in sys.argv[1:]:
    #rec_result = inference_pipeline('https://isv-data.oss-cn-hangzhou.aliyuncs.com/ics/MaaS/ASR/test_audio/asr_example_zh.wav')
    rec_result = inference_pipeline(filename)
    print(rec_result)
23 浏览
17 爬虫
0 评论