Podcast
播客制作:规划播客内容、制作音视频、生成片段和拓展多平台受众。
Create and grow podcasts by planning episodes, producing audio or video, generating clips, and building audience across formats.
clawhub install podcast使用OpenAI TTS Python库进行文本转语音,生成自然逼真的语音输出
Generate natural and realistic speech output using OpenAI TTS Python library for text-to-speech conversion
# 安装 Skill(会下载 SKILL.md 到 .claude/skills/) clawhub install openai-tts-python # 之后直接对 Claude 说"用 openai-tts-python 帮我…"即可
# 同样的安装命令,兼容所有支持 SKILL.md 的 AI 编程工具 clawhub install openai-tts-python
此 Skill 兼容 OpenClaw 标准。 安装后自动生成 SKILL.md 文件,任何支持 OpenClaw 协议的 AI Agent(Claude Code、Cursor、Windsurf 等)均可直接调用。
需要 OpenAI 账户和 API Key,按使用量计费,质量高成本较低
OPENAI_API_KEY environment variable must be setopenai, pydub (optional, for long text)from openai import OpenAI
import os
client = OpenAI(api_key=os.getenv('OPENAI_API_KEY'))
response = client.audio.speech.create(
model="tts-1", # or "tts-1-hd" for higher quality
voice="onyx", # choose from: alloy, echo, fable, onyx, nova, shimmer
input="Your text here",
speed=1.0 # 0.25 to 4.0 (optional)
)
with open("output.mp3", "wb") as f:
for chunk in response.iter_bytes():
f.write(chunk)
# Basic
python -c "
from openai import OpenAI
client = OpenAI()
response = client.audio.speech.create(model='tts-1', voice='onyx', input='Hello world')
open('output.mp3', 'wb').write(response.content)
"
from openai import OpenAI
from pydub import AudioSegment
import tempfile
import os
import re
client = OpenAI()
MAX_CHARS = 4096
def split_text(text):
if len(text) <= MAX_CHARS:
return [text]
chunks = []
sentences = re.split(r'(?<=[.!?])\s+', text)
current = ''
for sentence in sentences:
if len(current) + len(sentence) + 1 <= MAX_CHARS:
current += (' ' if current else '') + sentence
else:
if current:
chunks.append(current)
current = sentence
if current:
chunks.append(current)
return chunks
def generate_tts(text, output_path, voice='onyx', model='tts-1'):
chunks = split_text(text)
if len(chunks) == 1:
response = client.audio.speech.create(model=model, voice=voice, input=text)
with open(output_path, 'wb') as f:
f.write(response.content)
else:
segments = []
for chunk in chunks:
response = client.audio.speech.create(model=model, voice=voice, input=chunk)
with tempfile.NamedTemporaryFile(suffix='.mp3', delete=False) as tmp:
tmp.write(response.content)
segments.append(AudioSegment.from_mp3(tmp.name))
os.unlink(tmp.name)
combined = segments[0]
for seg in segments[1:]:
combined += seg
combined.export(output_path, format='mp3')
return output_path
# Usage
generate_tts("Your long text here...", "output.mp3", voice="nova")
mp3 (default), opus, aac, flacresponse = client.audio.speech.create(
model="tts-1",
voice="onyx",
input="Hello",
response_format="opus" # or mp3, aac, flac
)
from openai import OpenAI, APIError, RateLimitError
import time
client = OpenAI()
def generate_with_retry(text, voice='onyx', max_retries=3):
for attempt in range(max_retries):
try:
response = client.audio.speech.create(
model="tts-1",
voice=voice,
input=text
)
return response.content
except RateLimitError:
if attempt < max_retries - 1:
time.sleep(2 ** attempt) # Exponential backoff
continue
raise
except APIError as e:
print(f"API Error: {e}")
raise
return None
def article_to_podcast(article_text, output_file):
intro = "Welcome to today's article reading."
outro = "Thank you for listening."
full_text = f"{intro}\n\n{article_text}\n\n{outro}"
generate_tts(full_text, output_file, voice='nova', model='tts-1-hd')
print(f"Podcast saved to {output_file}")
def batch_tts(texts, output_dir, voice='onyx'):
import os
os.makedirs(output_dir, exist_ok=True)
for i, text in enumerate(texts):
output_path = os.path.join(output_dir, f"audio_{i+1}.mp3")
generate_tts(text, output_path, voice=voice)
print(f"Generated: {output_path}")
openai-tts-python --text "欢迎使用AI语音助手,请问有什么可以帮助您" --voice nova --output greeting.mp3 --speed 1.0播客制作:规划播客内容、制作音视频、生成片段和拓展多平台受众。
Create and grow podcasts by planning episodes, producing audio or video, generating clips, and building audience across formats.
clawhub install podcast使用 OpenAI 的 gpt-4o-mini-transcribe 模型转录音频文件,支持词汇提示和文本替换功能。
Transcribe audio files using OpenAI's gpt-4o-mini-transcribe model with vocabulary hints and text replacements. Requires uv (https://docs.astral.sh/uv/).
clawhub install voice-transcribe播客章节和亮点生成:从播客音频或文本自动提取章节标记、精彩片段和节目说明。
Create chapters, highlights, and show notes from podcast audio or transcripts. Use when a user wants chapter markers, highlight clips, or show-note drafts without publishing or distribution actions.
clawhub install podcast-chaptering-highlights