import gradio as gr from youtube_timestamper.core import YoutubeTimestamper import datetime def timestamp(url, q_thresh): yt_timestamper = YoutubeTimestamper(url) yt_timestamper.suggest_question_timestamps(q_thresh) output="" for t in yt_timestamper.timestamps: timestamp = f"{datetime.timedelta(seconds=t[0])}" timestamp = timestamp.split(".")[0].rjust(8, "0") stamp = f"{timestamp} {t[1]}" output += "\n" + stamp output += "\n\nCreated using youtube-timestamper - https://ilangurudev.github.io/youtube-timestamper/" return output.strip() title = "Youtube Timestamper" description = "Create timestamps for youtube interview videos using NLP." article = "For more details visit https://ilangurudev.github.io/youtube-timestamper/ " iface = gr.Interface(fn=timestamp, inputs=["text", gr.inputs.Slider(0, 50, 1, 15)], outputs="text", title=title, description=description, article=article, examples=[["https://www.youtube.com/watch?v=QGCvycOXs2M", 20], ["https://www.youtube.com/watch?v=RvwynqDUoQE", 20]],) iface.launch()