Spaces:
Runtime error
Runtime error
File size: 1,848 Bytes
6c226f9 d790c0b 88183ad 0db4cce 6c226f9 0db4cce 6c226f9 0db4cce 6c226f9 0db4cce a56fbd7 0db4cce 6c226f9 0db4cce 6c226f9 d959af8 3c0cd8e 6c226f9 0db4cce 7097513 88ca9aa 7097513 6c226f9 b95b5ca 6c226f9 b95b5ca 6c226f9 d959af8 6c226f9 0db4cce 6c226f9 7097513 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
import gradio as gr
import os
from gradio_client import Client
def transcribe_audio(youtube_url: str, task: str = "transcribe", return_timestamps: bool = True, api_name: str = "/predict_2") -> dict:
"""
Transcribe audio from a given YouTube URL using a specified model.
Parameters:
- youtube_url (str): The YouTube URL to transcribe.
- task (str, optional): The task to perform. Default is "transcribe".
- return_timestamps (bool, optional): Whether to return timestamps. Default is True.
- api_name (str, optional): The API endpoint to use. Default is "/predict_2".
Returns:
- dict: The transcription result.
"""
client = Client("https://sanchit-gandhi-whisper-jax.hf.space/")
result = client.predict(youtube_url, task, return_timestamps, fn_index=7)
return result
MODEL_NAME = "openai/whisper-large-v2"
demo = gr.Blocks()
EXAMPLES = [
("https://www.youtube.com/watch?v=H1YoNlz2LxA", "translate"),
]
yt_transcribe = gr.Interface(
fn=transcribe_audio,
inputs=[
gr.inputs.Textbox(lines=1, placeholder="Paste the URL to a YouTube video here", label="YouTube URL"),
gr.inputs.Radio(["transcribe", "translate"], label="Task", default="transcribe"),
gr.inputs.Checkbox(label="Return timestamps")
],
outputs=["html", "text"],
layout="horizontal",
theme="huggingface",
title="Whisper Large V2: Transcribe YouTube",
description=(
"Transcribe long-form YouTube videos with the click of a button! Demo uses the checkpoint"
f" [{MODEL_NAME}](https://huggingface.co/{MODEL_NAME}) and 🤗 Transformers to transcribe video files of"
" arbitrary length."
),
allow_flagging="never",
examples=EXAMPLES
)
with demo:
gr.TabbedInterface([yt_transcribe], [ "YouTube"])
demo.launch(enable_queue=True)
|