本地部署 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:

相关推荐
Aaron1588几秒前
RFSOC+VU13P/VU9P+GPU通用一体化硬件平台
人工智能·算法·fpga开发·硬件架构·硬件工程·信息与通信·基带工程
与硝酸1 分钟前
从 Claude Code 源码看 Agent 系统设计:主流框架都在解决的问题与各自的解法
人工智能·后端
Luminbox紫创测控3 分钟前
氙灯太阳光模拟器如何获得AM 1.5G标准太阳光谱?
运维·人工智能·5g
轮到我狗叫了4 分钟前
Few-shot Novel Category Discovery-少样本新类发现
人工智能·机器学习·支持向量机
龙腾AI白云4 分钟前
深度学习实战:Transformer模型文本翻译应用
人工智能·深度学习
美狐美颜SDK开放平台5 分钟前
直播美颜SDK选型避坑指南:功能与性能对比
人工智能·音视频·美颜sdk·直播美颜sdk·短视频美颜sdk
一次旅行6 分钟前
新闻简报2026-4-1
人工智能·量子计算
码农的神经元13 分钟前
从零实现 LLaMA 架构:一步步构建轻量级大语言模型
人工智能·语言模型·llama
xu_wenming15 分钟前
ESP32 运行TinyML模型准确性影响因素
人工智能·深度学习·机器学习
renhongxia116 分钟前
大模型Prompt实战:精准生成专业技术文档
人工智能·微服务·语言模型·自然语言处理·机器人·prompt