Spaces:
Build error
Build error
File size: 1,107 Bytes
9cce471 |
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 |
import gradio as gr
from langchain_community.document_loaders import YoutubeLoader
def load_youtube_transcript(url, language):
"""
YouTubeビデオから日本語のトランスクリプトを取得する。
Args:
url (str): YouTubeビデオのURL。
language (str): トランスクリプトの言語。
Returns:
list: ドキュメントオブジェクトのリスト。
"""
loader = YoutubeLoader.from_youtube_url(url, language=language, add_video_info=False)
return loader.load()
# Gradioインターフェースの作成
iface = gr.Interface(
fn=load_youtube_transcript,
inputs=[
gr.Textbox(label="YouTubeビデオのURL", lines=1),
gr.Dropdown(label="言語", choices=["ja", "en"], value="ja"),
],
outputs=[
gr.Textbox(label="トランスクリプト", lines=10),
],
title="YouTubeトランスクリプト取得",
description="YouTubeビデオのURLと言語を入力して、トランスクリプトを取得してください。"
)
# インターフェースの実行
iface.launch(share=True) |