windows系统安装whisper-webui

安装一个开源项目真不容易,折腾了一天,总算搞好了,在此将安装过程记录下来。

To run this WebUI, you need to have git, 3.10 <= python <= 3.12, FFmpeg.

系统:windows11

显卡:RTX 4090 D

安装git

在电脑E盘新建projects文件夹,从命令行进行该文件夹,使用命令:

git clone https://github.com/jhj0517/Whisper-WebUI.git

将whisper-webui下载到projects文件夹中,再从命令行进行Whisper-WebUI文件夹。

安装miniconda

用于创建虚拟环境,之前思考过用python自带的venv,但venv无法指定python版本,所以只能选用miniconda。使用命令:

conda create -p E:projectsWhisper-WebUIwwb312 python=3.11

创建虚拟环境文件夹wwb312,python版本选3.11,最开始我选用的是3.12,但是后面步骤没走通,改用3.11后走通了,但并不见得就是3.12的问题。在此只是记录走通的路线,其他路线未必就走不通。
使用命令:

conda activate E:projectsWhisper-WebUIwwb312

激活虚拟环境。

安装项目依赖

Whisper-WebUI文件夹中有个requirements.txt文件,记录了项目的所有依赖,起初并没有安装成功,误打误撞修改了文件中的一些内容,安装成功了,修改后的内容如下:

--extra-index-url https://download.pytorch.org/whl/cu126

# Update above --extra-index-url according to your device.

## Nvidia GPU
# CUDA 12.6 : https://download.pytorch.org/whl/cu126
# CUDA 12.8 : https://download.pytorch.org/whl/cu128

## Intel GPU
# https://download.pytorch.org/whl/xpu


torch
torchaudio

faster-whisper==1.1.1
transformers==4.47.1
gradio
gradio-i18n==0.3.0
pytubefix
ruamel.yaml==0.18.6
pyannote.audio==3.3.2

执行以下命令:

pip install  -r requirements.txt

安装项目依赖,但安装失败,又改成以下命令:

pip install -r requirements.txt --index-url https://pypi.tuna.tsinghua.edu.cn/simple

使用github镜像进行安装,安装成功。

使用本地模型

whisper-webui即支持使用openai的whisper模型,也支持faster-whisper模型。两者有一些差别:

  • openai的模型转写速度很慢,实际工作中几乎无法使用,而faster-whisper则速度很快;
  • openai的模型可以自动下载,而faster-whisper模型则总是下载失败,需提前在huggingface上进行下载;
  • openai模型是.pt格式的,faster-whisper模型是.bin结尾的,如果已经提前下载好了.pt模型,可以直接复制到models->Whisper文件夹下。
    使用openai模型的命令如下:

python app.py --whisper_type whisper --whisper_model_dir "models/Whisper"

使用faster-whisper模型的命令如下:

python app.py --whisper_type faster-whisper --faster_whisper_model_dir "models/Whisper/faster-whisper"

且需将下载好的faster-whisper模型文件夹提前复制到faster-whisper目录下,文件夹名称为models–Systran–faster-whisper-large-v3

局域网访问

修改app.py中的代码:

# server_name=args.server_name, # 注释掉
server_name="0.0.0.0",                   # 新增加

由于我选用的是faster-whisper模型,即便提前下载好了模型,并复制到faster-whisper目录下,可是启动时依然会报连不上huggingface的错误提示,于是我修改了modules->whisper->faster_whisper_inference.py文件中的内容:

self.model = faster_whisper.WhisperModel(
            "large-v3",                                       # 新增加
            device=self.device,
            model_size_or_path=self.current_model_size,
            download_root=self.model_dir,
            compute_type=self.current_compute_type,
            # local_files_only=local_files_only # 注释掉
            local_files_only=True                     # 新增加
)

起初在使用openai模型时还遇到一个报错,什么错忘记了,请百度AI修改了下代码,wwb312->lib->site-packages->whisper->transcribe.py:

# options = DecodingOptions(**kwargs, temperature=t)  # 注释掉
options = DecodingOptions(**{k: v for k, v in kwargs.items() if k !=  progress_callback }, temperature=t)                                # 新增加

修改后就正常了,但是并不知道是什么意思。

将项目复制到专用局域网

这一步比较顺利,将项目文件夹整个复制过去就可以了,启动方法都是一样的,当然,要先装好miniconda,才能激活虚拟坏境。

项目配置文件

在configs文件中有个项目配置文件default_parameters.yaml,一个奇怪的地方是在客户端里修改一些参数好像可以改变这个配置文件里的内容,机制不清楚,但终可以靠直接修改这个配置文件来重置初始参数。

音频编码格式

起初我用的是ADPCM_IMA_WAV编码格式的录音文件,该编码格式的音频采样率只有4k/s,whisper不支持,后来改成16k/s的采样率,才正常开始转写。

注意

我最初使用ADPCM_IMA_WAV编码格式的音频进行转写时,由于faster-whisper根本就不支持,所以它什么都没有听到,但whisper-webui的转写窗口竟然返回了一句话,而这句话是含有敏感词的,这引起了我的警觉,最好还是不要在连接互联网的电脑上使用这个项目。

参考文献

https://www.bilibili.com/video/BV1baNYzMEMp/?spm_id_from=333.337.search-card.all.click&vd_source=6a41650dc0dd5dbb5cd506ccfac27206

https://blog.csdn.net/gitblog_07073/article/details/148940887

© 版权声明
THE END
如果内容对您有所帮助,就支持一下吧!
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容