StevenChen16 commited on
Commit
8392829
·
verified ·
1 Parent(s): 9fa6eeb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -3
app.py CHANGED
@@ -1,8 +1,14 @@
1
- import gradio as gr
2
  import whisperx
3
 
4
- # 加载WhisperX模型
5
- model = whisperx.load_model("large-v3", device="cpu") # 如果有GPU,可将"cpu"改为"cuda"
 
 
 
 
 
 
6
 
7
  def transcribe(audio_path):
8
  # 使用WhisperX进行转录
 
1
+ import torch
2
  import whisperx
3
 
4
+ # 检测设备类型
5
+ device = "cuda" if torch.cuda.is_available() else "cpu"
6
+
7
+ # 设置计算类型
8
+ compute_type = "float16" if device == "cuda" else "int8"
9
+
10
+ # 加载 WhisperX 模型
11
+ model = whisperx.load_model("large-v3", device=device, compute_type=compute_type)
12
 
13
  def transcribe(audio_path):
14
  # 使用WhisperX进行转录