本地部署 faster-whisper

本地部署 faster-whisper

  • [1. 创建虚拟环境](#1. 创建虚拟环境)
  • [2. 安装依赖模块](#2. 安装依赖模块)
  • [3. 创建 Web UI](#3. 创建 Web UI)
  • [4. 启动 Web UI](#4. 启动 Web UI)
  • [5. 访问 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 audio
    segments, info = model.transcribe(audio_file, beam_size=5, language=language)

    # Prepare the output
    transcription = ""
    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:

相关推荐
嘟哩DuliDuli1 分钟前
剧本节点输入归一化:文本来源、版本与下游引用
android·人工智能·安全·ai·软件工程
小小AK3 分钟前
仓库调拨单同步实战:从营销云调拨出库到金蝶云星辰调拨单的一次完整落地
人工智能
电子元件小说家8 分钟前
2026年秋季开关与编码器行业观察:应用趋势与选型验证建议
人工智能
小瓜66911 分钟前
2026 科普:企业级 Work Agent 的基础能力框架
人工智能
Mr Robot19 分钟前
AI 赋能光伏发电量预测:从特征工程到 LSTM/XGboost 双基线实战
人工智能·能源
迪飞特科技23 分钟前
大模型接入业务系统:API、本地部署、RAG、智能体四种路线怎么选
java·数据库·人工智能·知识图谱·deepseek·本地化大模型
狂奔solar24 分钟前
Harness²:Google 如何让 AI 自己“调教“AI——递归代理优化框架深度拆解
人工智能
viperrrrrrrrrr726 分钟前
SFT 微调指南
人工智能
海姐软件测试29 分钟前
Python 自动化与 AI 结合:基于 Jenkins 的回归验证实践
人工智能·python·自动化
回眸&啤酒鸭30 分钟前
【回眸】纳米 AI 搜索效果实测与能力展示
人工智能