Spaces:
Build error
Build error
File size: 948 Bytes
2ec5fa6 | 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 | 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)
|