← 返回
未分类 Key 中文

Coze Tts

Text-to-Speech (TTS) using Coze API. Convert text to natural-sounding speech audio files. Supports multiple voices and output formats (mp3, ogg_opus, wav, pcm).
使用 Coze API 进行文本转语音 (TTS)。将文本转换为自然的语音音频文件。支持多种音色和输出格式 (mp3、ogg_opus、wav、pcm)。
franklu0819-lang franklu0819-lang 来源
未分类 clawhub v1.0.3 1 版本 100000 Key: 需要
★ 0
Stars
📥 547
下载
💾 25
安装
1
版本
#audio#coze#latest#speech#tts#voice

概述

Coze Text-to-Speech (TTS)

Convert text to natural-sounding speech using Coze API.

Setup

1. Get your API Key:

Get a key from Coze Platform

2. Set it in your environment:

export COZE_API_KEY="your-key-here"

Supported Output Formats

  • MP3 - Default format, widely compatible
  • OGG_OPUS - Optimized for streaming and messaging
  • WAV - Uncompressed audio
  • PCM - Raw audio data

Usage

Basic TTS

Convert text to speech with default settings:

bash scripts/text_to_speech.sh "你好,这是测试语音"

Save to Specific File

bash scripts/text_to_speech.sh "你好世界" -o output.mp3

Use Different Voice

bash scripts/text_to_speech.sh "你好" -v 2

Change Output Format

bash scripts/text_to_speech.sh "你好" -f ogg_opus

Full Options

bash scripts/text_to_speech.sh "要转换的文本" -o output.mp3 -v 1 -f mp3

Parameters:

  • text (required): Text to convert to speech
  • -o, --output (optional): Output file path (default: auto-generated)
  • -v, --voice (optional): Voice ID (default: 1)
  • -f, --format (optional): Output format - mp3/ogg_opus/wav/pcm (default: mp3)

Output

The script saves the audio file and outputs:

  • File path
  • File size
  • Audio duration (if ffprobe is available)

Example output:

✓ Audio saved: coze_tts_20260324_235030_a1b2c3d4.mp3
  Size: 25.3 KB
  Duration: ~3 seconds

Workflow Examples

Generate Notification Audio

bash scripts/text_to_speech.sh "您有一条新消息" -o notification.mp3

Create Voice Greeting

bash scripts/text_to_speech.sh "欢迎使用 Coze 语音服务" -v 2 -o greeting.mp3

Generate OGG for Messaging

bash scripts/text_to_speech.sh "你好" -f ogg_opus -o message.ogg

Batch Generate

for text in "你好" "谢谢" "再见"; do
    bash scripts/text_to_speech.sh "$text" -o "${text}.mp3"
done

Integration with Other Skills

Combine with coze-asr for voice conversation:

# 1. User speaks -> ASR converts to text
bash coze-asr/scripts/speech_to_text.sh input.ogg

# 2. Process text with AI...

# 3. AI response -> TTS converts to speech
bash coze-tts/scripts/text_to_speech.sh "AI的回复" -o response.mp3

Troubleshooting

Authentication Error:

  • Check COZE_API_KEY is set correctly
  • Verify API key has TTS permissions

Invalid Voice ID:

  • Voice ID should be a number (int64 format)
  • Try voice_id: 1 as default

File Not Created:

  • Check write permissions in output directory
  • Ensure sufficient disk space

Limitations

  • Text length limits apply (check Coze documentation)
  • Rate limits may apply based on your plan
  • Some voices may not support all output formats

API Reference

  • Endpoint: POST https://api.coze.cn/v1/audio/speech
  • Authentication: Bearer token (COZE_API_KEY)
  • Content-Type: application/json

Required Environment Variables

VariableDescriptionRequired
---------------------------------
COZE_API_KEYCoze API authentication keyYes

Required Tools

ToolPurposeRequired
-------------------------
jqJSON processingYes
ffprobeAudio duration detectionOptional

License

MIT

版本历史

共 1 个版本

  • v1.0.3 当前
    2026-03-30 15:47 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

design-media

Openai Whisper

steipete
使用 Whisper CLI 进行本地语音转文字(无需 API 密钥)
★ 330 📥 93,634
design-media

Nano Banana Pro

steipete
使用 Nano Banana Pro (Gemini 3 Pro Image) 生成或编辑图像。支持文生图、图生图及 1K/2K/4K 分辨率,适用于图像创建、修改及编辑请求,使用 --input-image 指定输入图像。
★ 429 📥 116,762
design-media

UI/UX Pro Max

xobi667
提供 UI/UX 设计智能与实现指导,帮助打造精美界面。适用于 UI 设计、UX 流程、信息架构、视觉风格、设计系统/标记、组件规格、文案/微文案、无障碍及前端 UI(HTML/CSS/JS、React、Next.js、Vue、Svelte
★ 216 📥 47,299