Spaces:
Build error
Build error
Commit
·
5855353
1
Parent(s):
69b1e14
second update
Browse files
app.py
CHANGED
@@ -1,23 +1,22 @@
|
|
1 |
import gradio as gr
|
2 |
import whisperx
|
3 |
-
import whisper
|
4 |
|
5 |
-
|
6 |
-
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
result = model.transcribe(
|
|
|
11 |
|
12 |
-
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
return {"aligned": result_aligned["segments"], "word_segments": result_aligned["word_segments"]}
|
19 |
-
|
20 |
-
inputs = gr.inputs.Audio(source="upload", type="filepath")
|
21 |
-
outputs = gr.outputs.JSON()
|
22 |
-
|
23 |
-
gr.Interface(fn=transcribe, inputs=inputs, outputs=outputs).launch()
|
|
|
1 |
import gradio as gr
|
2 |
import whisperx
|
|
|
3 |
|
4 |
+
# 加载WhisperX模型
|
5 |
+
model = whisperx.load_model("base", device="cpu") # 如果有GPU,可将"cpu"改为"cuda"
|
6 |
|
7 |
+
def transcribe(audio_path):
|
8 |
+
# 使用WhisperX进行转录
|
9 |
+
result = model.transcribe(audio_path)
|
10 |
+
return result['text']
|
11 |
|
12 |
+
# 创建Gradio接口
|
13 |
+
iface = gr.Interface(
|
14 |
+
fn=transcribe,
|
15 |
+
inputs=gr.Audio(source="upload", type="filepath"),
|
16 |
+
outputs="text",
|
17 |
+
title="WhisperX 语音转文字",
|
18 |
+
description="上传音频文件,使用WhisperX模型进行转录。"
|
19 |
+
)
|
20 |
|
21 |
+
if __name__ == "__main__":
|
22 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|