Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,7 @@ import gradio as gr
|
|
| 2 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
| 3 |
from datasets import load_dataset
|
| 4 |
import torch
|
| 5 |
-
import librosa
|
| 6 |
|
| 7 |
# 加载 Whisper 模型和 processor
|
| 8 |
model_name = "openai/whisper-large-v3-turbo"
|
|
@@ -15,8 +15,8 @@ ds = load_dataset("CoIR-Retrieval/CodeSearchNet-php-queries-corpus")
|
|
| 15 |
|
| 16 |
def transcribe(audio_path):
|
| 17 |
# 加载音频文件并转换为信号
|
| 18 |
-
audio, sr = librosa.load(audio_path, sr=16000)
|
| 19 |
-
input_values = processor(
|
| 20 |
|
| 21 |
# 模型推理
|
| 22 |
with torch.no_grad():
|
|
@@ -32,7 +32,7 @@ def transcribe(audio_path):
|
|
| 32 |
# Gradio 界面
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=transcribe,
|
| 35 |
-
inputs=gr.Audio( type="filepath"),
|
| 36 |
outputs="text",
|
| 37 |
title="Whisper Transcription for Developers",
|
| 38 |
description="使用 Whisper 和 bigcode 数据集转录开发者相关术语。"
|
|
|
|
| 2 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
| 3 |
from datasets import load_dataset
|
| 4 |
import torch
|
| 5 |
+
# import librosa
|
| 6 |
|
| 7 |
# 加载 Whisper 模型和 processor
|
| 8 |
model_name = "openai/whisper-large-v3-turbo"
|
|
|
|
| 15 |
|
| 16 |
def transcribe(audio_path):
|
| 17 |
# 加载音频文件并转换为信号
|
| 18 |
+
# audio, sr = librosa.load(audio_path, sr=16000)
|
| 19 |
+
input_values = processor(audio_path, return_tensors="pt", sampling_rate=16000).input_values
|
| 20 |
|
| 21 |
# 模型推理
|
| 22 |
with torch.no_grad():
|
|
|
|
| 32 |
# Gradio 界面
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=transcribe,
|
| 35 |
+
inputs=gr.Audio(sources="microphone", type="filepath"),
|
| 36 |
outputs="text",
|
| 37 |
title="Whisper Transcription for Developers",
|
| 38 |
description="使用 Whisper 和 bigcode 数据集转录开发者相关术语。"
|