欢迎光临
我们一直在努力

MacbookPro M5电脑部署Qwen ASR 1.7B本地模型

MacbookPro M5电脑部署Qwen ASR 1.7B本地模型 真正的“从0开始”的 Qwen3-ASR 和 Qwen3-TTS 本地部署全攻略。 整个教程分为四大步,每一步都请按顺序执行,你会非常顺利地跑通这两个强大的语音模型。

💻 第一步:准备工作(把电脑“工具箱”备好)

在下载模型之前,我们需要先配置好基础环境。Mac 的玩法跟 Windows 略有不同,我们按部就班来。 1.打开终端:在“启动台”的“其他”文件夹中找到“终端”并打开。这是接下来所有操作的地方。 2.安装 Homebrew(如果还没有):Homebrew 是 Mac 的软件包管理器,可以帮我们安装 ffmpeg 等必要组件。在终端粘贴以下命令并回车,根据提示输入开机密码(输入时屏幕不显示,是正常的):

Bash
/bin/bash -c \”$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\”

操作路径和执行结果:

Bash
[user]MacBook-Pro / % /bin/bash -c \”$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\”
==> Checking for `sudo` access (which may request your password)...
Password:*************
==> This script will install:
/opt/homebrew/bin/brew
/opt/homebrew/share/doc/homebrew
/opt/homebrew/share/man/man1/brew.1
/opt/homebrew/share/zsh/site-functions/_brew
/opt/homebrew/etc/bash_completion.d/brew
/opt/homebrew
/etc/paths.d/homebrew
==> The following new directories will be created:
/opt/homebrew/bin
/opt/homebrew/etc
/opt/homebrew/include
/opt/homebrew/lib
/opt/homebrew/sbin
/opt/homebrew/share
/opt/homebrew/var
/opt/homebrew/opt
/opt/homebrew/share/zsh
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/var/homebrew
/opt/homebrew/var/homebrew/linked
/opt/homebrew/Cellar
/opt/homebrew/Caskroom
/opt/homebrew/Frameworks

Press RETURN/ENTER to continue or any other key to abort:
==> /usr/bin/sudo /usr/bin/install -d -o root -g wheel -m 0755 /opt/homebrew
==> /usr/bin/sudo /bin/mkdir -p /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /bin/chmod ug=rwx /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /bin/chmod go-w /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
==> /usr/bin/sudo /usr/sbin/chown [user] /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/bin/chgrp admin /opt/homebrew/bin /opt/homebrew/etc /opt/homebrew/include /opt/homebrew/lib /opt/homebrew/sbin /opt/homebrew/share /opt/homebrew/var /opt/homebrew/opt /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions /opt/homebrew/var/homebrew /opt/homebrew/var/homebrew/linked /opt/homebrew/Cellar /opt/homebrew/Caskroom /opt/homebrew/Frameworks
==> /usr/bin/sudo /usr/sbin/chown -R [user]:admin /opt/homebrew
==> Downloading and installing Homebrew...
remote: Enumerating objects: 321925, done.
remote: Counting objects: 100% (212/212), done.
remote: Compressing objects: 100% (118/118), done.
remote: Total 321925 (delta 119), reused 141 (delta 94), pack-reused 321713 (from 2)
remote: Enumerating objects: 55, done.
remote: Counting objects: 100% (34/34), done.
remote: Total 55 (delta 34), reused 34 (delta 34), pack-reused 21 (from 1)
==> /usr/bin/sudo /bin/mkdir -p /etc/paths.d
==> /usr/bin/sudo tee /etc/paths.d/homebrew
/opt/homebrew/bin
==> /usr/bin/sudo /usr/sbin/chown root:wheel /etc/paths.d/homebrew
==> /usr/bin/sudo /bin/chmod a+r /etc/paths.d/homebrew
==> Updating Homebrew...
==> Downloading https://ghcr.io/v2/homebrew/core/portable-ruby/blobs/sha256:1c98fa49eacc935640a6f8e10a2bf33f14cfc276804b71ddb658ea45ba99d167
################################################################################################################################################ 100.0%
==> Pouring portable-ruby-3.4.8.arm64_big_sur.bottle.tar.gz
==> Installation successful!

==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
https://docs.brew.sh/Analytics
No analytics data has been sent yet (nor will any be during this install run).

==> Homebrew is run entirely by unpaid volunteers. Please consider donating:
https://github.com/Homebrew/brew#donations

==> Next steps:
– Run these commands in your terminal to add Homebrew to your PATH:
echo >> /Users/[user]/.zprofile
echo \’eval \”$(/opt/homebrew/bin/brew shellenv zsh)\”\’ >> /Users/[user]/.zprofile
eval \”$(/opt/homebrew/bin/brew shellenv zsh)\”
– Run brew help to get started
– Further documentation:
https://docs.brew.sh

3.安装 ffmpeg:ffmpeg 是处理音频和视频的核心工具,ASR 和 TTS 都离不开它。在终端执行:

Bash
brew install ffmpeg

以上代码在本地环境执行报错,后续采用pip命令执行成功。

Plain Text
pip install ffmpeg

执行结果

Bash
[user]@[user]deMacBook-Pro / % brew install ffmpeg
zsh: command not found: brew
[user]@[user]deMacBook-Pro / % pip install ffmpeg
Defaulting to user installation because normal site-packages is not writeable
Collecting ffmpeg
Downloading ffmpeg-1.4.tar.gz (5.1 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: ffmpeg
Building wheel for ffmpeg (pyproject.toml) ... done
Created wheel for ffmpeg: filename=ffmpeg-1.4-py3-none-any.whl size=6127 sha256=8adc4f9f6d2c012f1449f5f50e97429facd5d34993039ee31d139bd1b3d2a590
Stored in directory: /Users/[user]/Library/Caches/pip/wheels/1d/57/24/4eff6a03a9ea0e647568e8a5a0546cdf957e3cf005372c0245
Successfully built ffmpeg
Installing collected packages: ffmpeg
Successfully installed ffmpeg-1.4

4.验证 Python:M5 芯片的 Mac 自带 Python 3。 在终端输入 python3 –version,如果显示版本号(如 3.9 或更高),说明环境就绪。 执行结果

Plain Text
Python 3.9.6

注意:该版本无法和ASR模型匹配,需要更新到最新版本。 5.通过brew 安装python最新版本即可。 通过brew更新Python版本 指定版本命令:

Plain Text
pip install python3@3.13

目前该环境安装了3.13和3.14两个版本。 查询python所有安装的版本命令:

Plain Text
brew list –formula | grep python

安装pyevn管理Python版本

Plain Text
brew install pyenv

执行结果:

Java
✔︎ JSON API cask.jws.json Downloaded 15.3MB/ 15.3MB
✔︎ JSON API formula.jws.json Downloaded 31.9MB/ 31.9MB
==> Fetching downloads for: pyenv
✔︎ Bottle Manifest pyenv (2.6.23) Downloaded 19.9KB/ 19.9KB
✔︎ Bottle Manifest m4 (1.4.21) Downloaded 9.5KB/ 9.5KB
✔︎ Bottle Manifest pkgconf (2.5.1) Downloaded 12.2KB/ 12.2KB
✔︎ Bottle Manifest autoconf (2.72) Downloaded 19.7KB/ 19.7KB
✔︎ Bottle pkgconf (2.5.1) Downloaded 121.7KB/121.7KB
✔︎ Bottle autoconf (2.72) Downloaded 1.1MB/ 1.1MB
✔︎ Bottle m4 (1.4.21) Downloaded 282.7KB/282.7KB
✔︎ Bottle pyenv (2.6.23) Downloaded 1.4MB/ 1.4MB
==> Installing dependencies for pyenv: m4, autoconf and pkgconf
==> Installing pyenv dependency: m4
==> Pouring m4–1.4.21.arm64_tahoe.bottle.tar.gz
🍺 /opt/homebrew/Cellar/m4/1.4.21: 14 files, 817KB
==> Installing pyenv dependency: autoconf
==> Pouring autoconf–2.72.arm64_tahoe.bottle.1.tar.gz
🍺 /opt/homebrew/Cellar/autoconf/2.72: 72 files, 3.8MB
==> Installing pyenv dependency: pkgconf
==> Pouring pkgconf–2.5.1.arm64_tahoe.bottle.tar.gz
🍺 /opt/homebrew/Cellar/pkgconf/2.5.1: 28 files, 532.2KB
==> Installing pyenv
==> Pouring pyenv–2.6.23.arm64_tahoe.bottle.tar.gz
🍺 /opt/homebrew/Cellar/pyenv/2.6.23: 1,462 files, 4.7MB
==> Running `brew cleanup pyenv`...
Disable this behaviour by setting `HOMEBREW_NO_INSTALL_CLEANUP=1`.
Hide these hints with `HOMEBREW_NO_ENV_HINTS=1` (see `man brew`).

🎙️ 第二步:部署 Qwen3-ASR(让电脑“听懂”你的话)

我们将使用 qwen-asr 这个官方工具包,它内置了网页界面,操作起来最简单。

1.创建独立的 Python 环境:这是一个非常好的习惯,可以避免不同项目间的依赖冲突。 a.注意:终端不要到根目录,需要 cd ~ 命令。 Bash

创建名为 qwen-asr-env 的虚拟环境 ,创建虚拟环境指定Python版本,见下3.14为python版本号

python3.14 -m venv venv

激活这个环境

source venv/bin/activate

备用命令 Markdown

退出当前虚拟环境

deactivate

删除旧的虚拟环境(可选)

rm -rf venv

激活后,终端行首会出现 (venv) 的提示。 验证Python版本是否正确使用

Plain Text
python3 –version

结果:

Python 3.14.3

执行下一步命令行:

Plain Text
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

2.安装核心库:在虚拟环境中,安装语音识别所需的包。

Bash
pip install -U qwen-asr torch torchaudio

Bash 执行结果

pip install torch torchaudio
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting torch
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/4f/93/716b5ac0155f1be70ed81bacc21269c3ece8dba0c249b9994094110bfc51/torch-2.10.0-cp314-cp314-macosx_14_0_arm64.whl (79.5 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 79.5/79.5 MB 12.1 MB/s 0:00:06
Collecting torchaudio
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cc/5c/0e54b162bd0d1ec2f87b545553af839f906b940888d0122cdef04b965385/torchaudio-2.10.0-cp314-cp314-macosx_11_0_arm64.whl (739 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 739.5/739.5 kB 10.3 MB/s 0:00:00
Collecting filelock (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9c/0f/5d0c71a1aefeb08efff26272149e07ab922b64f46c63363756224bd6872e/filelock-3.24.3-py3-none-any.whl (24 kB)
Collecting typing-extensions>=4.10.0 (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl (44 kB)
Collecting setuptools (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e1/c6/76dc613121b793286a3f91621d7b75a2b493e0390ddca50f11993eadf192/setuptools-82.0.0-py3-none-any.whl (1.0 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.0/1.0 MB 11.4 MB/s 0:00:00
Collecting sympy>=1.13.3 (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a2/09/77d55d46fd61b4a135c444fc97158ef34a095e5681d0a6c10b75bf356191/sympy-1.14.0-py3-none-any.whl (6.3 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 6.3/6.3 MB 12.2 MB/s 0:00:00
Collecting networkx>=2.5.1 (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9e/c9/b2622292ea83fbb4ec318f5b9ab867d0a28ab43c5717bb85b0a5f6b3b0a4/networkx-3.6.1-py3-none-any.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 12.4 MB/s 0:00:00
Collecting jinja2 (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/a1/3d680cbfd5f4b8f15abc1d571870c5fc3e594bb582bc3b64ea099db13e56/jinja2-3.1.6-py3-none-any.whl (134 kB)
Collecting fsspec>=0.8.5 (from torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e6/ab/fb21f4c939bb440104cc2b396d3be1d9b7a9fd3c6c2a53d98c45b3d7c954/fsspec-2026.2.0-py3-none-any.whl (202 kB)
Collecting mpmath<1.4,>=1.1.0 (from sympy>=1.13.3->torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/43/e3/7d92a15f894aa0c9c4b49b8ee9ac9850d6e63b03c9c32c0367a13ae62209/mpmath-1.3.0-py3-none-any.whl (536 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 536.2/536.2 kB 11.7 MB/s 0:00:00
Collecting MarkupSafe>=2.0 (from jinja2->torch)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b5/64/7660f8a4a8e53c924d0fa05dc3a55c9cee10bbd82b11c5afb27d44b096ce/markupsafe-3.0.3-cp314-cp314-macosx_11_0_arm64.whl (12 kB)
Installing collected packages: mpmath, typing-extensions, sympy, setuptools, networkx, MarkupSafe, fsspec, filelock, jinja2, torch, torchaudio
Successfully installed MarkupSafe-3.0.3 filelock-3.24.3 fsspec-2026.2.0 jinja2-3.1.6 mpmath-1.3.0 networkx-3.6.1 setuptools-82.0.0 sympy-1.14.0 torch-2.10.0 torchaudio-2.10.0 typing-extensions-4.15.0

[notice] A new release of pip is available: 26.0> 26.0.1
[notice] To update, run: pip install –upgrade pip

注意: Plain Text 如果指定版本号会报错,直接用上方代码直接执行,默认安装。

pip install torch==2.8.0 torchaudio==2.8.0 –index-url https://download.pytorch.org/whl/cpu
Looking in indexes: https://download.pytorch.org/whl/cpu
ERROR: Could not find a version that satisfies the requirement torch==2.8.0 (from versions: 2.9.0, 2.9.1, 2.10.0)
ERROR: No matching distribution found for torch==2.8.0

在 Mac 上,无需安装 flash-attn,系统会提示找不到,但这不影响运行,可以忽略 。 安装虚拟环境其它依赖库

pip install \”transformers==4.57.6\” \”nagisa==0.2.11\” \”soynlp==0.0.493\” \”accelerate==1.12.0\” \”qwen-omni-utils==0.0.8\” \”librosa==0.11.0\” \”soundfile==0.13.1\” \”sox==1.5.0\” \”gradio==6.5.1\” \”flask==3.1.2\” \”pytz==2025.2\” \”modelscope==1.34.0\”

Bash
执行结果:会自动检测当前环境并安装
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting transformers==4.57.6
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/03/b8/e484ef633af3887baeeb4b6ad12743363af7cce68ae51e938e00aaa0529d/transformers-4.57.6-py3-none-any.whl (12.0 MB)
Collecting nagisa==0.2.11
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7f/f2/4ea25b753df10a2a64079b05358b3e59e154f274b73f456d60a59e2e6f0b/nagisa-0.2.11-cp314-cp314-macosx_11_0_arm64.whl (21.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 21.4/21.4 MB 11.9 MB/s 0:00:01
Collecting soynlp==0.0.493
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/7e/50/6913dc52a86a6b189419e59f9eef1b8d599cffb6f44f7bb91854165fc603/soynlp-0.0.493-py3-none-any.whl (416 kB)
Collecting accelerate==1.12.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9f/d2/c581486aa6c4fbd7394c23c47b83fa1a919d34194e16944241daf9e762dd/accelerate-1.12.0-py3-none-any.whl (380 kB)
Collecting qwen-omni-utils==0.0.8
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a1/b1/dcdd69246a3c3c3bd6f6ced58e2307b3afbd894c4412c29fd49dd897e562/qwen_omni_utils-0.0.8-py3-none-any.whl (9.2 kB)
Collecting librosa==0.11.0
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b5/ba/c63c5786dfee4c3417094c4b00966e61e4a63efecee22cb7b4c0387dda83/librosa-0.11.0-py3-none-any.whl (260 kB)
Collecting soundfile==0.13.1
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a0/e5/58fd1a8d7b26fc113af244f966ee3aecf03cb9293cb935daaddc1e455e18/soundfile-0.13.1-py2.py3-none-macosx_11_0_arm64.whl (1.1 MB)

赞(0)
未经允许不得转载:171主机测评 » MacbookPro M5电脑部署Qwen ASR 1.7B本地模型
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址