import whisper import yt_dlp import gradio as gr import os import re import logging logging.basicConfig(level=logging.INFO) model = whisper.load_model("medium") def get_text(url): #try: if url != '': output_text_transcribe = '' with yt_dlp.YoutubeDL({'format': 'bestaudio', 'audio-format': 'wav', 'outtmpl': '%(id)s.%(ext)s'}) as ydl: # Extract information from the given YouTube URL and download the best audio format available info_dict = ydl.extract_info(url, download=True) # Prepare the filename of the downloaded audio file audio_file = ydl.prepare_filename(info_dict) #finally: # raise gr.Error("Exception: There was a problem transcribing the audio.") result = model.transcribe(audio_file, task="transcribe") return result['text'].strip() with gr.Blocks() as demo: gr.Markdown("