欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > 本地部署 faster-whisper

本地部署 faster-whisper

2025/2/2 3:56:16 来源:https://blog.csdn.net/engchina/article/details/140920185  浏览:    关键词:本地部署 faster-whisper

本地部署 faster-whisper

  • 1. 创建虚拟环境
  • 2. 安装依赖模块
  • 3. 创建 Web UI
  • 4. 启动 Web UI
  • 5. 访问 Web UI

在这里插入图片描述

1. 创建虚拟环境

conda create -n faster-whisper python=3.11 -y
conda activate faster-whisper

2. 安装依赖模块

pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu118
pip install faster-whisper
conda install matplotlib
pip install gradio

3. 创建 Web UI

# webui.py
import gradio as gr
from faster_whisper import WhisperModel# Initialize the model
# model_size = "large-v3"
model_size = "Systran/faster-whisper-large-v3"
model = WhisperModel(model_size, device="cuda", compute_type="float16")def transcribe_audio(audio_file, language):# Transcribe the audiosegments, info = model.transcribe(audio_file, beam_size=5, language=language)# Prepare the outputtranscription = ""for segment in segments:transcription += f"[{segment.start:.2f}s -> {segment.end:.2f}s] {segment.text}\n"detected_language = f"Detected language: {info.language} (probability: {info.language_probability:.2f})"return detected_language, transcription# Define Gradio interface
iface = gr.Interface(fn=transcribe_audio,inputs=[gr.Audio(type="filepath", label="Upload Audio"),gr.Dropdown(["en", "zh", "ja"], label="Select Language", value="en")],outputs=[gr.Textbox(label="Detected Language"),gr.Textbox(label="Transcription", lines=20)],allow_flagging='never',title="Audio Transcription with Faster Whisper",description="Upload an audio file and select the language to transcribe the audio to text. Choose 'auto' for automatic language detection."
)# Launch the interface
iface.launch()

4. 启动 Web UI

python webui.py

5. 访问 Web UI

使用浏览器打开 http://localhost:7860,
在这里插入图片描述

reference:

  • https://github.com/systran/faster-whisper
  • https://huggingface.co/Systran/faster-whisper-large-v3

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com