Skip to content

WTChien/YT_Summarizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YT Summarizer

一個使用 Streamlit 製作的 YouTube 影音摘要工具。

輸入 YouTube 影片網址後,程式會先抓取影片字幕,再透過 Google Gemini 生成繁體中文摘要與 5 個重點整理。

功能特色

  • 支援一般 YouTube 網址,例如 https://www.youtube.com/watch?v=...
  • 支援短網址,例如 https://youtu.be/...
  • 自動擷取影片字幕內容
  • 使用 Gemini 產生繁體中文摘要
  • 顯示 5 個重點整理
  • 以 Streamlit 提供簡單網頁介面

專案結構

.
├── app.py
├── Dockerfile
├── requirements.txt
└── README.md

使用技術

  • Python 3.12
  • Streamlit
  • Google Generative AI
  • YouTube Transcript API
  • python-dotenv

環境需求

  • Python 3.12 或相容版本
  • 可用的 Google Gemini API Key
  • 網路連線可存取 YouTube 與 Google AI 服務

安裝方式

  1. 複製專案
git clone <your-repo-url>
cd YT_Summarizer
  1. 安裝套件
pip install -r requirements.txt
  1. 建立 .env 檔案
GEMINI_API_KEY=your_gemini_api_key

本機執行

streamlit run app.py

啟動後,通常可在以下位址開啟:

http://localhost:8501

Docker 執行

  1. 建立映像檔
docker build -t yt-summarizer .
  1. 啟動容器
docker run --rm -p 8080:8080 --env GEMINI_API_KEY=your_gemini_api_key yt-summarizer

啟動後可在以下位址開啟:

http://localhost:8080

使用方式

  1. 開啟網頁介面
  2. 輸入 YouTube 影片網址
  3. 點擊「開始摘要」
  4. 等待系統抓取字幕並產生摘要
  5. 查看繁體中文摘要與 5 個重點

支援的網址格式

  • https://www.youtube.com/watch?v=VIDEO_ID
  • https://www.youtube.com/watch?v=VIDEO_ID&t=1s
  • https://youtu.be/VIDEO_ID
  • https://youtu.be/VIDEO_ID?si=xxx
  • 直接輸入 VIDEO_ID

注意事項

  • 影片必須有可取得的字幕,否則無法摘要
  • 程式目前優先抓取 zh-TWenzh-Hant 字幕
  • 若 API Key 未設定或無效,Gemini 摘要功能將無法使用
  • 摘要品質會受到原始字幕內容與模型輸出影響

目前流程說明

程式執行流程如下:

  1. 使用者輸入 YouTube 網址
  2. 程式解析出影片 ID
  3. 透過 YouTube Transcript API 抓取字幕
  4. 將字幕內容串接成完整文字
  5. 把文字送給 Gemini 模型進行摘要
  6. 在 Streamlit 頁面顯示結果

已安裝套件

目前 requirements.txt 內容如下:

streamlit
google-generativeai
youtube-transcript-api
dotenv

後續可改進方向

  • 支援更多字幕語言與自動語言判斷
  • 增加摘要長度或格式選項
  • 支援章節式整理
  • 對無字幕影片提供更清楚的錯誤提示
  • 加入影片標題、縮圖與中繼資訊顯示

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors