ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

VibeVoice ASR 部署实战:从 Docker + vLLM 推理服务到 Gradio 网络 Demo 的完整搭建

VibeVoice ASR 部署实战:从 Docker + vLLM 推理服务到 Gradio 网络 Demo 的完整搭建 VibeVoice ASR 部署实战从 Docker vLLM 推理服务到 Gradio 网络 Demo 的完整搭建【免费下载链接】VibeVoiceOpen-Source Frontier Voice AI项目地址: https://gitcode.com/GitHub_Trending/vib/VibeVoice本篇基于仓库内的部署指南 setup_gradio_demo.md讲清楚 VibeVoice ASR语音识别模型在 GPU 环境下的端到端部署流程如何用一条docker run命令拉起基于 vLLM 的高性能推理服务支持单卡与多卡数据并行验证 OpenAI 兼容 API再叠加 Gradio Web Demo 生成可公开访问的试听/转录页面。读完本文你可以独立完成 ASR 服务的容器化部署、多 GPU 扩容与故障排查并深入理解启动脚本 start_server.py 与服务端插件的实现细节。一、整体架构两个组件一条链路整个 Demo 由两个独立进程组成均运行在同一个 Docker 容器内ASR 服务vllm/vllm-openai:v0.14.1官方镜像中运行 start_server.py它负责装依赖、拉模型、生成 tokenizer 文件最终启动vllm serve对外提供 OpenAI 兼容的/v1/chat/completions接口模型名注册为vibevoiceGradio 前端gradio_asr_demo_api_video.py 通过 HTTP 调用上面的 API提供音频/视频上传、流式转写、分段试听与字幕生成界面可用--share生成gradio.live公网链接。从 pyproject.toml 可以看到vibevoice包通过vllm.general_plugins入口点注册vllm_plugin:register_vibevoice这意味着 vLLM 无需修改源码即可识别并加载 VibeVoice 模型——安装即插即用。二、前置条件具备 CUDA 的 GPU多卡部署需更多显存设备支持 GPU 的 Dockernvidia-docker本地已克隆 VibeVoice 仓库容器会把当前目录挂载为/appgit clone https://github.com/microsoft/VibeVoice.git cd VibeVoice三、Step 1 — 启动 ASR 服务启动脚本 start_server.py 会自动完成五件事安装系统依赖FFmpeg、libsndfile1、以 vLLM 插件方式安装 VibeVoice、从 Hugging Face 下载模型默认microsoft/VibeVoice-ASR、通过 generate_tokenizer_files.py 生成 tokenizer 文件、最后exec启动vllm serve。3.1 单 GPU默认docker run -d --gpus device0 --name vibevoice-asr-demo \ --ipchost \ -p 6001:6001 \ -e VIBEVOICE_FFMPEG_MAX_CONCURRENCY64 \ -e PYTORCH_ALLOC_CONFexpandable_segments:True \ -v $(pwd):/app \ -w /app \ --entrypoint bash \ vllm/vllm-openai:v0.14.1 \ -c python3 /app/vllm_plugin/scripts/start_server.py --port 6001两个环境变量的作用VIBEVOICE_FFMPEG_MAX_CONCURRENCY64控制音频解码FFmpeg的并发上限DP 模式下启动脚本还会自动为每个 worker 单独注入该值PYTORCH_ALLOC_CONFexpandable_segments:True开启 PyTorch 可扩展显存分段分配缓解显存碎片导致的 OOM。3.2 多 GPU 数据并行负载均衡docker run -d --gpus device0,1,2,3 --name vibevoice-asr-demo \ --ipchost \ -p 6001:6001 \ -e VIBEVOICE_FFMPEG_MAX_CONCURRENCY64 \ -e PYTORCH_ALLOC_CONFexpandable_segments:True \ -v $(pwd):/app \ -w /app \ --entrypoint bash \ vllm/vllm-openai:v0.14.1 \ -c python3 /app/vllm_plugin/scripts/start_server.py --port 6001 --dp 4--dp 4表示在 4 张 GPU 上各跑 1 个独立副本。从源码 start_dp_server 可以看到其实现细节为每个副本分配独立 GPU通过CUDA_VISIBLE_DEVICES与内部端口前端端口 100、101……自动安装并启动nginx 反向代理采用least_conn最少连接调度worker 数默认为2 × 副本数对外只暴露一个端口设计注释说明这样做是为了规避 vLLM 内置 DP 协调器在大音频载荷下的单进程 HTTP 瓶颈每个后端最多等待 10 分钟就绪任何一个 worker 退出都会触发整体优雅关闭。Tip--dp N用于 N 路数据并行吞吐扩容推荐--tp N用于张量并行单卡放不下大模型时切分。两者默认均为 1详细原理见 vibevoice-vllm-asr.md。3.3 检查日志docker logs -f vibevoice-asr-demo等待出现Application startup complete.即表示服务就绪含模型下载首次约 2 分钟以上。3.4 启动脚本暴露的全部参数对照 start_server.py 的 argparse 定义除--port和--dp/--tp外还可调节参数说明默认值--model, -mHugging Face 模型 IDmicrosoft/VibeVoice-ASR--port, -p服务端口8000--max-num-seqs单批次最大并发序列数64--max-model-len最大模型上下文长度支撑长音频65536--gpu-memory-utilization显存占用比例0.8--skip-deps跳过系统依赖安装off--skip-tokenizer跳过 tokenizer 文件生成off这些值最终会传入由_build_vllm_cmd拼出的vllm serve命令其中固定携带--dtype bfloat16、--no-enable-prefix-caching、--enable-chunked-prefill、--allowed-local-media-path /app等 ASR 场景针对性配置。四、Step 2 — 验证服务# Check the model is loaded curl http://localhost:6001/v1/models预期输出{ data: [{ id: vibevoice, ... }] }4.1 用真实音频快速测试仓库自带的 test_api.py 是最小验证客户端docker exec -it vibevoice-asr-demo \ python3 /app/vllm_plugin/tests/test_api.py /app/en-Alice_woman.wav \ --url http://localhost:6001从源码看该脚本会把音频 base64 编码后以audio_url形式放入/v1/chat/completions请求prompt 中要求模型按Start time / End time / Speaker ID / Content四个键输出 JSON并以流式方式接收增量结果结束后打印总耗时与RTF实时因子 处理时长 / 音频时长可用于直观评估服务吞吐。它还支持--hotwords参数把热词以 with extra info 形式嵌入 prompt提升专有名词、人名识别准确率python3 /app/vllm_plugin/tests/test_api.py /app/en-Alice_woman.wav --hotwords Microsoft,Azure,VibeVoice测试音频路径可按需替换为挂载目录中的任意 wav/mp3 文件。五、Step 3 — 启动 Gradio DemoGradio 进程与 ASR 服务分离便于单独重启前端而不动推理服务。这里用 tmux 让进程在容器内后台常驻。5.1 安装 tmuxdocker exec vibevoice-asr-demo apt-get install -y tmux5.2 在 tmux 中启动 Gradiodocker exec vibevoice-asr-demo bash -c \ PYTHONUNBUFFERED1 tmux new-session -d -s gradio \ PYTHONUNBUFFERED1 python3 /app/vllm_plugin/scripts/gradio_asr_demo_api_video.py \ --api_url http://localhost:6001 --share \ 21 | tee /tmp/gradio.logPYTHONUNBUFFERED1保证 Python 输出不缓冲日志能实时写入/tmp/gradio.log这也是排查日志为空的关键。5.3 获取 Share 链接等待约 20 秒后docker exec vibevoice-asr-demo cat /tmp/gradio.log预期看到✅ Connected to API: http://localhost:6001 | Model: vibevoice Starting VibeVoice ASR Demo * Running on local URL: http://0.0.0.0:7860 * Running on public URL: https://xxxxxx.gradio.livegradio.live链接为公网可访问的临时分享有效期约 1 周。5.4 Gradio 启动参数Flag说明默认值--api_url URLvLLM 服务地址http://localhost:8000--share创建 Gradio 公网链接off--port PORT本地 Gradio 端口7860--cloudflared用 Cloudflare 隧道代替 Gradio shareoff--max_video_size MB允许上传的视频大小上限50补充源码中同样存在但文档未强调的两个参数见 gradio_asr_demo_api_video.py--model_name不指定时自动从/v1/models探测与--max_new_tokens默认 4096。启动时 demo 会调用demo.queue(default_concurrency_limit10)即队列模式下最多 10 个请求并发处理天然支持多人同时使用。5.5 Demo 前端的实现要点从 gradio_asr_demo_api_video.py 的源码结构看它不只是简单的转写页面多格式兼容识别.wav/.mp3/.flac/.ogg/.opus/.m4a等音频与.mp4/.webm/.mov/.mkv等视频扩展名视频会先用 ffmpeg 抽取 16kHz 单声道 MP3 音轨再提交识别流式输出VibeVoiceAPIClient.transcribe_streaming以stream: True请求 API边收边向页面推送增量文本并解析usage字段展示 token 统计截断容错_parse_segments与_parse_truncated_segments会在响应被截断时尽力抢救出完整的分段Start/End/Speaker/Content避免长音频全军覆没分段试听与字幕转写完成后可按说话人分段并行切片ThreadPoolExecutor并生成 SRT / WebVTT 字幕文件热词上下文界面支持填入 context info拼入 prompt 后同样走热词增强识别路径。六、服务管理6.1 只停 Gradio保留 ASR 服务docker exec vibevoice-asr-demo tmux kill-session -t gradio重启 Gradio重跑 Step 3 中的 tmux 命令即可。6.2 全部停止docker stop vibevoice-asr-demo docker rm vibevoice-asr-demo七、一键完整示例GPU 0 端口 6001# 1. Start server docker run -d --gpus device0 --name vibevoice-asr-demo \ --ipchost -p 6001:6001 \ -e VIBEVOICE_FFMPEG_MAX_CONCURRENCY64 \ -e PYTORCH_ALLOC_CONFexpandable_segments:True \ -v $(pwd):/app -w /app \ --entrypoint bash \ vllm/vllm-openai:v0.14.1 \ -c python3 /app/vllm_plugin/scripts/start_server.py --port 6001 # 2. Wait for startup (~2 min), then verify docker logs -f vibevoice-asr-demo # wait for Application startup complete. curl http://localhost:6001/v1/models # 3. Install tmux and launch Gradio docker exec vibevoice-asr-demo apt-get install -y tmux docker exec vibevoice-asr-demo bash -c \ PYTHONUNBUFFERED1 tmux new-session -d -s gradio \ PYTHONUNBUFFERED1 python3 /app/vllm_plugin/scripts/gradio_asr_demo_api_video.py \ --api_url http://localhost:6001 --share \ 21 | tee /tmp/gradio.log # 4. Get the public link sleep 20 docker exec vibevoice-asr-demo cat /tmp/gradio.log八、故障排查问题处理办法CUDA out of memory换用其他 GPUdeviceX或在start_server.py中把--gpu-memory-utilization调低如0.7Gradio 日志为空多等一会约 30sGradio 会缓冲输出务必加PYTHONUNBUFFERED1Port already in use换端口或停掉占用容器docker stop name docker rm nameShare 链接显示 No interfaceGradio 仍在加载等待日志出现Application startup completetmux: command not found先执行docker exec container apt-get install -y tmux补充两条从源码可确认的排查线索DP 模式下每个后端就绪判定依赖其内部端口的/v1/models最长等待 10 分钟若日志停在 Waiting for all backends to be ready 应检查--gpus提供的卡数是否 ≥--dp × --tp--dp N启动前脚本会显式断言 GPU 数量充足数量不足会直接给出Need X GPUs ... but only Y available的明确报错。九、延伸阅读部署指南原文docs/setup_gradio_demo.mdvLLM ASR 服务完整说明TP/DP 原理、流式 API、热词docs/vibevoice-vllm-asr.md一键启动脚本vllm_plugin/scripts/start_server.pyGradio 前端实现vllm_plugin/scripts/gradio_asr_demo_api_video.pyAPI 测试客户端vllm_plugin/tests/test_api.py流式 Demo 的 FastAPI 服务端另一条部署路线vllm_plugin/asr_streaming_server.py【免费下载链接】VibeVoiceOpen-Source Frontier Voice AI项目地址: https://gitcode.com/GitHub_Trending/vib/VibeVoice创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表