import gradio as gr import speech_recognition as sr import moviepy.editor as mp def get_youtube_transcript(link): try: # Download and convert the YouTube video to audio video = mp.VideoFileClip(link) video.audio.write_audiofile("audio.wav") # Convert speech to text using Google Web Speech API recognizer = sr.Recognizer() with sr.AudioFile("audio.wav") as source: audio = recognizer.record(source) transcript = recognizer.recognize_google(audio) return transcript except Exception as e: return "Transcription Error: Could not transcribe the video" # Define the input and output components for Gradio inputs = gr.inputs.Textbox(label="YouTube Video Link") outputs = gr.outputs.Textbox() # Create the Gradio interface gr.Interface(fn=get_youtube_transcript, inputs=inputs, outputs=outputs, title="YouTube Video Transcriber").launch(debug=True)