Spaces:
Running
on
Zero
Running
on
Zero
File size: 724 Bytes
8392829 69b1e14 f13acc2 8392829 f13acc2 5855353 69b1e14 5855353 69b1e14 5855353 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import torch
import whisperx
# 检测设备类型
device = "cuda" if torch.cuda.is_available() else "cpu"
# 设置计算类型
compute_type = "float16" if device == "cuda" else "int8"
# 加载 WhisperX 模型
model = whisperx.load_model("large-v3", device=device, compute_type=compute_type)
def transcribe(audio_path):
# 使用WhisperX进行转录
result = model.transcribe(audio_path)
return result['text']
# 创建Gradio接口
iface = gr.Interface(
fn=transcribe,
inputs=gr.Audio(source="upload", type="filepath"),
outputs="text",
title="WhisperX 语音转文字",
description="上传音频文件,使用WhisperX模型进行转录。"
)
if __name__ == "__main__":
iface.launch()
|