可实现地语音聊天、控制电脑做出简单操作的功能。
可实现地语音聊天、控制电脑做出简单操作的功能。通过开源项目:语音转文字模型 SenseVoice,文字转语音模型 CosyVoice2,大语言模型服务 Ollama,键盘鼠标宏 KeymouseGo。LLMSPeech 可实现地语音聊天、控制电脑做出简单操作的功能。
2.1. 前期准备Windows 11 (10)安装 Git下载 ffmpeg并加入环境变量, 选择 Windows builds from gyan.dev ,选择 ffmpeg-git-essentials.7z。 解压后将 bin 加入环境变量 PATH 中下载 Ollama ,打开 PowerShell 下载一个非思考模型。qwen3 0.6b 版本用于测试连通性,qwen3:4b-instruct用于测试prompt。ollama run qwen3:qwen3:0.6b
ollama run qwen3:4b-instruct2.2. 安装虚拟环境
Miniconda(清华源), 下载 Miniconda3-py313_25.5.1-1-Windows-x86_64.exe 版本,安装时勾选 Add Miniconda3 to my PATH environment variable打开 PowerShell ,如果想要在 PowerShell 使用 conda ,开发环境可执行以下:添加权限,Y 确认,初始化,取消base环境自启动,关闭 PowerShell。若不执行,后续操作需要在 Anaconda PowerShell Prompt 中进行Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
conda init
conda config --set auto_activate_base false加入信任链接,安装虚拟环境,配置镜像源。conda tos accept --override-channels --channelhttps://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channelhttps://repo.anaconda.com/pkgs/r
conda tos accept --override-channels --channelhttps://repo.anaconda.com/pkgs/msys2
conda create -n llmspeech python=3.10 -y
conda activate llmspeech
python -m pip install -i https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple --upgrade pip
pip config set global.index-url https://mirrors.tuna.tsinghua.edu.cn/pypi/web/simple
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/linux-64/
conda config --set show_channel_urls yes
conda upgrade pip
2.3. 可跳过该步骤。单独测试各个模块和环境配置2.3.1. 安装 SenseVoiceSenseVoice 下载,配置环境,运行 python 脚本自动下载模型,等待显示成功。默认下载模型位置为 .cache\modelscope\hub\iic, 其中 speech_fsmn_vad_zh-cn-16k-common-pytorch 是 AuroModel 类的 vad_model 参数, SenseVoiceSmall 是 AuroModel 类的 model 参数。git clone https://github.com/FunAudioLLM/SenseVoice.git
conda create -n sensevoice python=3.10 -y
conda activate sensevoice
cd SenseVoice
pip install -r requirements.txt如果有英伟达显卡,最好使用 CUDA,这个命令在 CosyVoice 中也有pip install torch==2.3.1+cu121 torchaudio==2.3.1+cu121 -f https://download.pytorch.org/whl/torch_stable.html检测是否安装成功:将 demo_sensevoice.py 复制到 LLMSpeech 目录下,运行2.3.2. 安装 CosyVoiceCosyVoice,默认下载模型位置在 pretrained_models/CosyVoice2-0.5Bgit clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
cd CosyVoice
git submodule update --init --recursive
conda create -n cosyvoice -y python=3.10
conda activate cosyvoice
conda install -y -c conda-forge pynini==2.1.5
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com把 CosyVoice 重命名为 CosyVoice2, 然后把里面的 cosyvoice 文件夹复制到 LLMSpeech 根目录下载 CosyVoice2-0.5B 模型:把 demo\download_cosyvoice-0.5B.py 复制到 LLMSpeech 根目录下,运行检测是否安装成功:demo_cosyvoice.py 也复制到 LLMSpeech 根目录,应该可以直接运行。至此, CosyVoice 还有一个小问题,就是无法断网运行。将 assets/pys/wetext.py 覆盖复制到 wetext 包,参考路径 miniconda3\envs\cosyvoice\Lib\site-packages\wetext 这样 wetext 就不会在每次启动时联网了2.3.3. 安装 KeymouseGogit clone https://github.com/taojy123/KeymouseGo.git
cd KeymouseGo
pip install -r requirements-windows.txt
2.4. 配置环境2.4.1 安装依赖
pip install -r requirements.txt4.1.1 如果没有英伟达显卡,就注释掉第一行 --extra-index-url https://download.pytorch.org/whl/cu121,此时会会安装 pytorch cpu 版本,速度会慢。4.1.2 如果网络连接不畅,可以下载 UsbEAm Hosts Editor,自动优化 github, pytorch, ollama 的 host 文件。4.1.3 此时程序中的 wetext 会在启动时自动联网, LLMSpeech 无法断网运行。将 assets/pys/wetext.py 覆盖复制到 wetext 包,参考路径 miniconda3\envs\llmspeech\Lib\site-packages\wetext 这样 wetext 就不会在每次启动时联网了2.4.2 克隆必要仓库
git clone https://github.com/FunAudioLLM/SenseVoice.git
git clone https://github.com/taojy123/KeymouseGo.git
git clone --recursive https://github.com/FunAudioLLM/CosyVoice.git
cd CosyVoice
git submodule update --init --recursive将 CosyVoice 重命名为 CosyVoice2, 然后把里面的 cosyvoice 文件夹复制到 LLMSpeech 根目录2.4.3 安装 CosyVoice-0.5B 模型python demo/download_cosyvoice-0.5B.py2.4.4 下载其他模型将 demo 文件夹下的 demo_cosyvoice.py 和 demo_sensevoice.py 复制到 LLMSpeech 根目录运行。 其中运行 demo_sensevoice.py 后会自动下载需要的模型。2.5. 运行运行 LLMSpeech.py 即可2.5.1 双击运行如果是 Windows 10 系统需要去应用商店自行下载 Windows Terminal,Windows 11 自带 Windows Terminal。
static/image/hrline/1.gif
链接: https://pan.baidu.com/s/1rK-9oQPGnznQnuXq128kAg提取码下载:
页:
[1]