SuperAPI AI Directory

byted-podcast-tts

General & other

View repository

Updated 10-15 18:45

About this skill

Podcast TTS Skill

Based on the Volcano Engine Doubao speech synthesis WebSocket protocol (PodcastTTS,/api/v3/sami/podcasttts) synthesize a certain topic into podcast audio and save it as a local file. Supports:

  • Input a topic sentence or a web page address (it can also be a file download address, supporting pdf/word/txt formats) to generate a podcast
  • Output the podcast audio download link
  • Output the podcast segmented text (JSON)

Applicable scenarios

  1. The user mentions 生成播客 or 播客合成 and other related keywords.
  2. The user needs to generate a podcast-format audio file for a certain topic.
  3. The user needs to generate a podcast-format audio file from the content of a certain web page or file.
  4. The user needs to generate a podcast-format audio file from the content of a file uploaded by the user or from a long context.

Usage steps

  1. Analyze the content for which the user needs to synthesize a podcast, and prepare the input to be synthesized:prompt_text(the original topic, generally no more than 20 characters) or input_url(web page address or file download address) or text(content read from a file uploaded by the user or a relatively long text, generally more than 200 characters).
  2. Before running the script, first cd to this skill directory:skills/byted-podcast-gen。
  3. Configure authentication (environment variables or command-line arguments).
  4. Run the script:python scripts/podcast.py [参数]. Refer to the examples section below.
  5. According to the audio_path / texts / audio_url in the JSON output by the script, use the generated result. If there is audio_url which is a URL with an expiration time, it can be returned to the user, audio_path is a local file path, which can be provided to the user for download.

Environment variables and authentication

This script authenticates through WebSocket Header. You can pass it in via command-line arguments, or configure environment variables (recommended, to avoid leaking credentials in command-line history):

  • Required:MODEL_SPEECH_API_KEY

Script parameters

Parameter Short form Required Description
--text No Input the original long text (used whenaction=0 )
--input_url No URL of the input text (used whenaction=0 , choose one of the two)
--prompt_text No Prompt text (required whenaction=4 )
--action No Podcast type:0(original 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, including:

  • status: "success" or "error"
  • task_id: task identifier (used to locate a generation task)
  • audio_path: final audio local path
  • texts: segmented text JSON string, the text list corresponding to each speaker.
  • audio_url: the audio download address returned by the server
  • error: error message on failure

Error handling

  • If an error is reported indicating that MODEL_SPEECH_API_KEYis missing: check whether the environment variable or command-line argument has been configured. If it does not exist, prompt the user for input, then set it in the environment variable.
  • If a server-side error is received (MsgType.Error): based on the error message, check account permissions, the resource ID, the input content, and whether the service has been activated.
  • If the server-side error received contains the keyword quota , it indicates that the current account has exceeded the quota and needs to upgrade the Volcano Engine Doubao Speech podcast service.
  • When python execution is missing related packages, 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