This video shows how to install and use Whisper large-v3-turbo in free google colab for transcription in gradio which is a finetuned version of a pruned Whisper large-v3.
Code:
!pip install git+https://github.com/huggingface/transformers gradio
import torch
from transformers import pipeline
pipe = pipeline("automatic-speech-recognition",
"openai/whisper-large-v3-turbo",
torch_dtype=torch.float16,
device="cuda:0")
pipe("/content/samples_jfk.wav")
import gradio as gr
def transcribe(inputs):
if inputs is None:
raise gr.Error("No audio file")
text = pipe(inputs, generate_kwargs={"task": "transcribe"}, return_timestamps=True)["text"]
return text
demo = gr.Interface(
fn=transcribe,
inputs=[
gr.Audio(sources=["microphone", "upload"], type="filepath"),
],
outputs="text",
title="Whisper Large V3 Turbo: Transcribe Audio",
description=(
"Transcribe long-form microphone or audio inputs. Thanks to HuggingFace"
),
allow_flagging="never",
)
demo.launch()
No comments:
Post a Comment