Spaces:
Build error
Build error
import spaces | |
import torch | |
import gradio as gr | |
from transformers import pipeline | |
from transformers.pipelines.audio_utils import ffmpeg_read | |
MODEL_NAME = "openai/whisper-large-v3" | |
BATCH_SIZE = 8 | |
FILE_LIMIT_MB = 1000 | |
device = 0 if torch.cuda.is_available() else "cpu" | |
pipe = pipeline( | |
task="automatic-speech-recognition", | |
model=MODEL_NAME, | |
chunk_length_s=30, | |
device=device, | |
) | |
def audio_transcribe(inputs, task): | |
if inputs is None: | |
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting your request.") | |
text = pipe(inputs, batch_size=BATCH_SIZE, generate_kwargs={"task": task}, return_timestamps=True)["text"] | |
return text | |
with gr.Blocks() as transcriberUI: | |
gr.Markdown( | |
""" | |
# Ola! | |
Clicar no botao abaixo para selecionar o Audio a ser transcrito! | |
Ambiente Demo disponivel 24x7. Running on ZeroGPU with openai/whisper-large-v3 | |
""") | |
inp = gr.File(label="Arquivo de Audio", show_label=True, type="file_path", file_count="single", file_types=["mp3"]) | |
transcribe = gr.Textbox(label="Transcricao", show_label=True, show_copy_button=True) | |
inp.upload(audio_transcribe, inp, transcribe) | |
if __name__ == "__main__": | |
transcriberUI.launch() | |