這是一個基於 Cloudflare Workers 的音頻轉錄服務,使用 Whisper AI 模型將音頻檔案轉換為繁體中文文字。
- 🎵 支援多種音頻格式 (MP3, WAV等)
- 🤖 使用 Cloudflare Whisper AI 模型進行轉錄
- 🇹🇼 自動轉換為繁體中文輸出
- ⚡ 高效能的 Cloudflare Workers 平台
- 🌐 RESTful API 介面
- 🧠 使用
@cf/openai/gpt-oss-120b自動整理逐字稿重點
npm installnpm run cf-typegennpm run dev --remote開發伺服器將在 http://localhost:8787 啟動。
curl http://localhost:8787應該返回 "Hello World!"
POST /api/transcription/
- Content-Type:
multipart/form-data - 請求體: 使用 form field
file上傳音頻檔案 - 回應: 轉錄後的繁體中文文字
首先創建測試檔案目錄並放入測試音頻:
# 測試音頻轉錄
curl -X POST \
-F "file=@./files/ja.mp3" \
http://localhost:8787/api/transcription/ja# 測試.wav音頻轉錄
curl -X POST \
-F "file=@./files/test.wav" \
http://localhost:8787/api/transcription/# WAV 檔案
curl -X POST \
-F "file=@./files/test.wav" \
http://localhost:8787/api/transcription/
# M4A 檔案
curl -X POST \
-F "file=@./files/test.m4a" \
http://localhost:8787/api/transcription/AI 自動摘要會將逐字稿切成最大約 15,000 字符的區塊,透過 @cf/openai/gpt-oss-120b 生成每段重點後再彙整為完整大綱。若內容超過 8 段,會自動限制只處理前幾段以避免超時。
curl -X POST \
-F "file=@./files/sample.txt" \
http://localhost:8787/api/test-ai以上端點會讀取文字檔並返回 AI 整理的大綱結果。
curl -X POST \
-F "file=@./files/transcript-2025-07-16.txt" \
http://localhost:8787/api/upload-transcription成功後會:
- 將檔案原文上傳到 R2 儲存
- 自動產出大綱並寫入 D1 資料庫
- 回傳
meeting_id與 R2 儲存鍵值
npm run deploy部署後,將上述 curl 命令中的 URL 替換為你的 Worker 域名:
curl -X POST \
-F "file=@./files/test.mp3" \
https://your-worker-name.your-subdomain.workers.dev/api/transcription/npm run dev- 啟動本地開發伺服器npm run deploy- 部署到 Cloudflare Workersnpm run cf-typegen- 生成類型定義檔案npm test- 執行測試
-
AI 模型未配置錯誤
- 確保
wrangler.jsonc中有正確的 AI 綁定配置 - 執行
npm run cf-typegen重新生成類型
- 確保
-
音頻檔案過大
- Cloudflare Workers 有請求大小限制
- 建議音頻檔案小於 100MB
-
轉錄結果為空
- 檢查音頻檔案是否包含可識別的語音
- 確認音頻格式是否受支援
在本地開發時,可以查看 console 輸出來了解轉錄過程:
npm run dev -- --local- Runtime: Cloudflare Workers
- AI 模型:
@cf/openai/whisper-large-v3-turbo - 語言處理:
chinese-conv(簡轉繁) - TypeScript: 完整類型支援
請參考項目授權條款。