生成 Podcast (API 方法)
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
。
Gemini Enterprise 提供 API,可根據來源文件生成 Podcast。輸出內容與使用者在筆記本中產生的播客非常相似。
透過 API 生成 Podcast 非常適合批次作業,例如您可能有數十或數百本書籍、文章或課程,並想為每項內容生成 Podcast。
Podcast API 是獨立的 API,也就是說,您不需要 NotebookLM Enterprise 筆記本、Gemini Enterprise 授權或資料存放區。您只需要已啟用的 Google Cloud 專案和 Podcast API 使用者角色。
API 的輸入內容是 context
元素陣列。這是生成 Podcast 的來源素材。輸入內容可以是文字、圖片、音訊和影片。內容陣列的權杖總數必須少於 100,000 個。
如需支援的類型清單,請參閱本頁的「Gemini 2.5 Flash」一節,瞭解圖片、文件、影片和音訊的技術規格。
輸出
API 會輸出 MP3 格式的 Podcast。
事前準備
使用 API 生成 Podcast 前,請務必備妥下列項目:
根據脈絡輸入內容生成 Podcast
使用下列指令呼叫 podcast 方法,產生 Podcast。
輸入內容為多媒體物件陣列,例如文字、圖片,以及音訊和影片片段。
REST
如要生成及匯出 Podcast,請按照下列步驟操作:
執行下列 curl 指令:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1/projects/PROJECT_ID/locations/global/podcasts" \
-d '{
"podcastConfig": {
"focus": "FOCUS",
"length": "LENGTH",
"languageCode": "LANGUAGE_CODE"
},
"contexts": [
{
"MEDIA_TYPE_1": "MEDIA_CONTENT_1"
},
{
"MEDIA_TYPE_2": "MEDIA_CONTENT_2"
}
],
"title": "PODCAST_TITLE",
"description": "PODCAST_DESCRIPTION"
}'
更改下列內容:
PROJECT_ID
:專案 ID。
FOCUS
:提示,建議 Podcast 的主題。
LENGTH
:有兩個選項:
SHORT
(通常需要 4 到 5 分鐘)
STANDARD
(通常約 10 分鐘,但如果資料集較小,時間可能會更短)
LANGUAGE_CODE
:選用。指定 Podcast 的語言代碼。請使用 BCP47 定義的語言標記。如果未提供語言代碼,系統會以英文生成 Podcast。
MEDIA_TYPE_N
:指定要用來生成 Podcast 的媒體類型。允許的類型如下:
text
. 純文字。
blob
。如為純文字以外的所有媒體類型,請使用這個類型,並以原始位元組上傳資料。
MEDIA_CONTENT_N
:內容本身,以純文字或原始位元組表示。內容陣列的權杖總數不得超過 10 萬個。
PODCAST_TITLE
:Podcast 的標題。這項資訊可供內部使用,您也可以選擇向使用者顯示。
PODCAST_DESCRIPTION
:Podcast 的說明。這項資訊可供內部使用,您也可以選擇向使用者顯示。
指令與結果範例
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://discoveryengine.googleapis.com/v1/projects/my-project-123/locations/global/podcasts" \
-d '{
"podcastConfig": {
"focus": "Can you talk about how to find a job in Google?",
"length": "SHORT"
},
"contexts": [
{
"text": "Breaking into Google is a highly competitive endeavor, attracting millions of applicants globally due to its reputation as a top employer, its innovative work, and comprehensive perks. Success hinges on a multi-faceted approach, starting with meticulously tailored online applications that incorporate job description keywords for ATS and showcasing Googlyness—a blend of curiosity, collaborative spirit, and leadership potential. The rigorous, multi-stage interview process involves recruiter screens, behavioral interviews (often using the STAR method), and for technical roles, demanding coding challenges and system design questions that assess not just correct answers but also problem-solving thought processes and communication skills. Networking for referrals and informational interviews can significantly boost visibility, but ultimately, thorough preparation through mock interviews and platforms like LeetCode, combined with patience and resilience through the often lengthy process, are paramount for navigating this challenging but rewarding path."
},
{
"text": "Finding your way into a career at Google begins with their comprehensive careers website, a digital gateway brimming with opportunities. To embark on this journey, you first navigate the job board, using keywords like software engineer or product manager to pinpoint potential roles. To refine your search, utilize the array of filters available for location, experience level, degree, skills, and even specific Google organizations. You can even browse by team if you have a particular department in mind, like Engineering and Technology or Marketing and Communications. Once you discover a promising position, delve into its detailed description, paying close attention to the minimum qualifications – these are the foundational criteria against which your application will be assessed. Remember, Google seeks out leaders who can perform at the highest level, and while experience is valued, internships or graduate programs can be a great entry point for those earlier in their career. When you are ready to apply, you will need to create a Careers Profile, using your Google Account for seamless sign-in and communication. Crucially, tailor your resume for each specific role, highlighting relevant experiences and quantifying your achievements with concrete data. While a one-page resume is generally preferred, a two-page resume is acceptable for those with more extensive experience. Notably, cover letters are not typically required unless explicitly stated in the job description. Google encourages quality over quantity, so strategically apply for up to three jobs every 30 days, choosing roles that truly align with your skills and passions. Once you have submitted your applications, your Careers Profile becomes your tracking center, where you can monitor the status of each submission, from Draft to Submitted. If you do not hear back within eight weeks, the search continues, though Google recruiters may proactively reach out for other opportunities later. Remember, perseverance and a solid understanding of Google values, combined with a continuously refined skill set and a well-prepared resume, will greatly enhance your chances of securing a position at this innovative company."
}
],
"title": "Find a job at Google ",
"description": "This podcast is based on two plain text documents that describe various aspects of getting a job at Google."
}'
{
"name": "projects/123456/locations/global/operations/create-podcast-54321"
}
生成 Podcast 需要幾分鐘的時間。
記下作業名稱,您需要在步驟 4 中使用這個名稱下載 Podcast。在上述範例中,作業名稱為 projects/123456/locations/global/operations/create-podcast-54321
。
(選用步驟) 輪詢 Podcast 建立作業的狀態。請參閱「取得長時間執行作業的詳細資料」。
作業完成後,請執行下列 curl 指令來下載 Podcast:
curl -v \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://discoveryengine.googleapis.com/v1/OPERATION_NAME:download?alt=media" \
--output FILENAME.mp3 -L
更改下列內容:
OPERATION_NAME
:您在步驟 2 記下的作業名稱。
FILENAME
:Podcast 的檔案名稱。
這個指令會將 Podcast 下載到本機目錄中的 MP3 檔案。
指令與結果範例
curl -v \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
"https://discoveryengine.googleapis.com/v1/projects/123456/locations/global/operations/create-podcast-54321:download?alt=media" \
--output my-podcast.mp3 -L
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Host discoveryengine.googleapis.com:443 was resolved.
...
{ [42044 bytes data]
100 14.3M 100 14.3M 0 0 10.9M 0 0:00:01 0:00:01 --:--:-- 29.7M
* Connection #0 to host discoveryengine.googleapis.com left intact
法規遵循
Podcast API 不符合客戶自行管理的加密金鑰 (CMEK) 規定,因此無法搭配 Gemini Enterprise 適用的 CMEK 使用。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-10-19 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-10-19 (世界標準時間)。"],[],[]]