Based on the Volcano Engine Doubao Speech Synthesis WebSocket Protocol (PodcastTTS,/api/v3/sami/podcasttts) synthesize a topic into podcast audio and save it as a local file. Supports:
- Input a topic text or a webpage address (can also be a file download address, supporting pdf/word/txt formats) to generate a podcast
- Output the podcast audio download link as-is (do not truncate or otherwise process it) and the generated local file for download. Verify whether the download link is downloadable; if downloadable, return it to the user; if not downloadable, only return the local file.
- Output podcast segment text (JSON)
Applicable Scenarios
- When the user mentions
生成播客or播客合成and other related keywords. - The user needs to generate an audio file in podcast form for a certain topic.
- The user needs to generate an audio file in podcast form from a certain webpage or file content.
- The user needs to generate an audio file in podcast form from user-uploaded file content or a long context.
Mandatory Rules (Highest Priority)
When you receive a user request to generate a podcast:
- Must and can only use this Skill's script to generate the podcast
- Topic Mode The user needs to generate an audio file in podcast form for a certain topic, use parameters
action=4andprompt_text= topic text. - Webpage Mode The user needs to generate an audio file in podcast form from a certain webpage or downloadable file content, use parameters
action=0andinput_url= webpage address or file download address. - File Mode The user needs to generate an audio file in podcast form from user-uploaded file content or a long context, use parameters
action=0andtext= the content read from the user-uploaded file or a relatively long text, generally more than 200 characters.
Usage Steps
- Analyze the content the user needs to synthesize into a podcast, and prepare the input to be synthesized:
prompt_text(original topic, generally no more than 20 characters) orinput_url(webpage address or file download address) ortext(the content read from the user-uploaded file or a relatively long text, generally more than 200 characters). - Before running the script, first
cdto this skill directory:skills/byted-podcast-gen。 - Configure authentication (environment variables or command-line parameters).
- Run the script:
python scripts/podcast.py [参数]. Refer to the example section below. - Based on the
audio_path/texts/audio_urlin the JSON output by the script, use the generation result; if there isaudio_urlit is a URL with an expiration time, return it to the user exactly as-is,audio_pathis a local file path, which can be provided to the user for download.
Script Parameters
| Parameter | Short Form | Required | Description |
|---|---|---|---|
--text |
No | Input the original long text (action=0 used when) |
|
--input_url |
No | URL of the input text (action=0 used when, choose one of the two) |
|
--prompt_text |
No | Prompt text (action=4 required) |
|
--action |
No | Podcast type:0(raw text/URL),4(prompt); default 4 |
|
--speaker_info |
No | Speaker configuration JSON (default {"random_order":false}) |
|
--encoding |
No | Audio format:mp3(default),wav、ogg_opus |
|
--output |
No | Final audio output file path (by default automatically generated to output/) |
Return value description
The script outputs JSON, containing:
status:"success"or"error"task_id: Task identifier (used to locate a generation task)audio_path: Final audio local pathtexts: Segmented text JSON string, the text list corresponding to each speaker.audio_url: The audio download address returned by the servererror: Error message on failure
Error handling
- If an error indicates a missing
MODEL_SPEECH_API_KEY: Check whether the environment variable or command-line parameter has been configured; if it does not exist, prompt the user for input, then set it to the environment variable. - If a server error is received (
MsgType.Error): Based on the error message, check the account permissions, resource ID, input content, and whether the service has been activated. - If the server error received contains the keyword
quota, it indicates that the current account has exceeded the quota and needs to upgrade the Volcano Engine Doubao Voice podcast service. - When Python execution lacks the relevant package, the dependencies need to be installed first:
pip install -r requirements.txt
Reference documentation
Example
# 基于话题生成播客音频
ptompt_text="豆包语音合成服务"
python scripts/podcast.py --prompt_text $ptompt_text --action 4
# 基于网页内容生成播客音频
url="https://www.volcengine.com/docs/6561/1668014?lang=zh"
python scripts/podcast.py --input_url $url --action 0
# 基于长文本内容生成播客音频
text="欢迎收听本期节目,我们聊聊人工智能的关键拐点……"
python scripts/podcast.py --text $text --action 0