Text To Speech 标志

Text To Speech

组织
sarvamai
text-to-speech

Write correct Sarvam Bulbul TTS code — bulbul:v4-flash persona speaker IDs (voice_language_style), REST, HTTP stream, WebSocket, pronunciation dictionaries, and v3/v4 traps (short names rejected on v4, param ranges). Use this skill when generating speech in an app with Python or JS/TS. For live TTS in chat via MCP, use sarvam-mcp instead.

Add to TypingMind

概览

发布者sarvamai
代码仓库skills
技能名称text-to-speech
星标数
72
复刻数
24
附带文件
仅含指令
许可协议Apache-2.0
链接
  • Markdown 格式的指令

    模型按需加载 SKILL.md 文件,因此只有在请求确实与该技能匹配时才会消耗 Token。

  • 兼容任何大语言模型

    AI 技能采用纯 Markdown,而非特定提供商的代码,因此可搭配 GPT、Claude、Gemini、Grok 或本地模型使用。

  • 指令自成一体

    模型所需的一切都包含在指令中,无需同步额外文件。

  • 开源

    由 sarvamai 发布于 GitHub。请在安装前查看技能的源文件。

安装

在 TypingMind 中安装 Text To Speech AI 技能,即可搭配任意大语言模型使用;也可以将其放入其他支持读取 SKILL.md 的智能体中。

1

安装到 TypingMind

TypingMind 可直接从 GitHub 文件夹安装技能:读取 SKILL.md,打包资源文件,并将结果保存在本地。

  1. 打开应用,前往“插件 → 技能”。
  2. 选择“从 GitHub 安装”。
  3. 粘贴下方的技能文件夹 URL 并确认。
    https://github.com/sarvamai/skills/tree/main/text-to-speech
  4. 请在每个需要使用该技能的聊天中启用它。
依次选择“插件 → 技能 → 添加技能 → 从 GitHub URL 导入”,然后粘贴文件夹 URL 并点击“继续”。
2

安装到其他智能体

任何支持 Agent Skills 格式的智能体都可以使用此技能,只需将文件夹复制到该智能体的技能目录中。

Claude Code — .claude/skills
git clone --depth 1 https://github.com/sarvamai/skills.git /tmp/skills
mkdir -p .claude/skills
cp -r /tmp/skills/text-to-speech .claude/skills/text-to-speech
复制后,请重启 Claude Code,以加载新技能。

在 TypingMind 中使用此技能

在任意 TypingMind 聊天中启用 Text To Speech,后续即可交由模型处理。技能的名称和描述会放在系统提示词中,一旦请求匹配,模型就会自动加载完整指令,无需您手动调用,且在实际使用前不会消耗 Token。

一旦请求与技能匹配,模型就会自动加载 Text To Speech。

兼容任何 AI 模型

AI 技能是纯 Markdown 指令,而非特定提供商的代码,因此 Text To Speech 不局限于最初适配的模型。只需在 TypingMind 中安装一次,即可搭配 GPT-5、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 或您自行运行的本地模型使用,全程使用您自己的 API 密钥。

  • 仅在需要时加载

    系统提示词中仅包含技能名称和描述。首次遇到匹配的请求时才会加载完整指令,因此技能未使用时,这些指令不会消耗 Token。

  • 在聊天中切换模型

    技能是指令而非代码,因此切换模型不会导致技能失效,新模型会读取同一个 SKILL.md。

技能指令

这是模型会加载的 SKILL.md 内容。请在安装前阅读,因为技能就是模型将遵循的指令。

Text-to-Speech — Bulbul

Live in-chat TTS → sarvam-mcp (sarvam_tools_tts_*). This skill = SDK code.

[!IMPORTANT] Auth: api-subscription-key header — NOT Authorization: Bearer. Base URL: https://api.sarvam.ai (NOT /v1 — that prefix is only for the OpenAI-compatible chat endpoint) SDK floor for the code below: Python sarvamai>=0.1.29, JS sarvamai@>=1.1.8. On older versions the TTS param is target_language_code — see Gotchas.

Model

bulbul:v4-flash — latest, use this for new integrations. Same REST / HTTP stream / WebSocket contract as v3. 200+ persona voices (222 IDs).

bulbul:v3 — what the API uses when model is omitted. Short names (shubh, priya). Still the right model for Malayalam and Odia, which have no v4 personas yet.

Speakers (v4 Flash)

IDs are lowercase voice_language_style: aparna_hi_customer, simran_en_customer, shubh_enhi_ads. Omit speaker and the default is shubh_enhi_ads. v2/v3 short names (shubh, priya, ishita, anushka) return 400.

The middle token is a language tag (hi, en, bn, gu, kn, mr, pa, ta, te) or enhi for English–Hindi code-mix. Use an _enhi_ persona when one utterance is genuinely mixed; a few English loanwords in Hindi script do not need it.

language_code still takes the usual BCP-47 values (hi-IN, en-IN, … including ml-IN and od-IN). There are no ml or od persona IDs — for those languages set model="bulbul:v3" and a v3 short name.

Use caseHindiEnglish
Customer careaparna_hi_customeraparna_en_companion
Salesaparna_hi_customer, shubh_hi_customersimran_en_sales
Collectionssimran_hi_recoveryshubh_en_recovery
Hinglish (one utterance)simran_enhi_customer—

Do not copy speaker="ishita" from the Voices “generate your own sample” snippet — that is a v3 short name and fails on v4-flash.

Coverage by language (live-verified 2026-10-06; one working persona each — pick others from the live list):

LanguageExample personaLanguageExample persona
en-INsimran_en_customer, sunny_en_socialmr-INishita_mr_conversational
hi-INaparna_hi_customer, shubh_hi_customergu-INbhavik_gu_conversation
hi-IN (Hinglish)shubh_enhi_ads (the default)kn-INchaitra_kn_conversation
bn-INroopa_bn_conversational, arnab_bn_conversationpa-INanand_pa_conversation
ta-INgokul_ta_narration, aravind_ta_adste-INkavitha_te_conversation

The roster changes. Sarvam renamed voices on 2026-10-06 (bappa_bn_conversation → arnab_bn_conversation, vetri_ta_ads/vetri_ta_suspense → aravind_ta_*), and the old IDs now 400. Do not hardcode IDs from memory or old blog posts. An unknown speaker returns 400 with the full live list, so the list is one bad request away. The API also lists 2 Assamese (_as_) personas that the docs catalog does not.

Quick Start (Python)

python
from sarvamai import SarvamAI
from sarvamai.play import save

client = SarvamAI()

response = client.text_to_speech.convert(
    text="नमस्ते, आप कैसे हैं?",
    language_code="hi-IN",
    model="bulbul:v4-flash",
    speaker="aparna_hi_customer",
    enable_preprocessing=True,
)
save(response, "output.wav")

# HTTP Stream (lower latency, binary audio)
chunks = []
for chunk in client.text_to_speech.convert_stream(
    text="Hello from Sarvam AI",
    language_code="en-IN",
    model="bulbul:v4-flash",
    speaker="simran_en_customer",
    output_audio_codec="wav",
):
    chunks.append(chunk)
audio = b"".join(chunks)

Quick Start (JavaScript/TypeScript)

typescript
import { SarvamAIClient } from "sarvamai";
import { writeFile } from "fs/promises";

const client = new SarvamAIClient({ apiSubscriptionKey: "YOUR_SARVAM_API_KEY" });

// REST
const response = await client.textToSpeech.convert({
    text: "नमस्ते, आप कैसे हैं?",
    language_code: "hi-IN",
    model: "bulbul:v4-flash",
    speaker: "aparna_hi_customer",
    enable_preprocessing: true,
});

// HTTP Stream (lower latency, returns BinaryResponse)
const streamResponse = await client.textToSpeech.convertStream({
    text: "Hello from Sarvam AI",
    language_code: "en-IN",
    model: "bulbul:v4-flash",
    speaker: "simran_en_customer",
    output_audio_codec: "wav",
});
const bytes = await streamResponse.bytes();
await writeFile("output.wav", bytes);

WebSocket Streaming

python
import asyncio
from sarvamai import AsyncSarvamAI

async def tts_stream():
    client = AsyncSarvamAI()
    async with client.text_to_speech_streaming.connect(model="bulbul:v4-flash") as ws:
        await ws.configure(
            target_language_code="hi-IN",
            speaker="aparna_hi_customer",
            output_audio_codec="wav",
        )
        await ws.convert("Your text here")
        await ws.flush()
        async for message in ws:
            pass  # base64 audio chunks

asyncio.run(tts_stream())

Character Limits

MethodMax Text
REST (convert)2,500 chars
HTTP Stream (convert_stream)3,500 chars
Legacy inputs array (raw REST)500 chars per item — send text instead to get the 2,500 limit
WebSocket2,500 chars/msg (keep <500 for lowest latency; send many messages per connection)

Gotchas

GotchaDetail
Set model or you get v3Omitting model selects bulbul:v3. v3 short names then work; v4 persona IDs do not. New code sets model="bulbul:v4-flash".
v3/v2 short names on v4shubh, priya, ishita, anushka, etc. are rejected. Use voice_language_style. Unknown IDs 400 with the live speaker list.
language_code is version-gatedPython >=0.1.29 and JS >=1.1.8 (both 2026-08-03) take language_code; earlier versions take target_language_code. Hard rename — no alias, no deprecation shim, and the JSON body key changed too, so the wrong name raises TypeError before any request goes out. Check with pip show sarvamai / npm ls sarvamai if you hit that.
WebSocket was not renamedPython ws.configure() still takes target_language_code (mapped to language_code on the wire). Docs that pass language_code= into ws.configure() raise TypeError. JS configureConnection() takes language_code.
JS method nameclient.textToSpeech.convert({...}) and .convertStream({...}) — camelCase. Stream returns BinaryResponse with .stream(), .bytes(), .blob().
pitch / loudness rangespitch −0.5–0.5 (default 0), loudness 0.1–2.5 (default 1), pace 0.5–2.0. Out-of-range values return 400. Bulbul v3 used to reject pitch / loudness; as of 2026-10-06 it accepts them too (live-verified). v2-only ranges in the model-page limits table do not apply.
Streaming codec defaultHTTP stream and WebSocket do not default to WAV. Set output_audio_codec (wav or mp3; also flac / aac on HTTP stream). opus can appear in the schema and currently errors on /text-to-speech.
Sample ratespeech_sample_rate 8000, 16000, 24000 and 48000 verified on v4-flash REST (the returned WAV matches the requested rate).
Sample rate >24kHz32kHz, 44.1kHz, 48kHz only via REST, not streaming. Omitted → 22050 Hz.
REST responseBase64-encoded audio in response.audios[0]. Use sarvamai.play.save() or base64.b64decode(). Writing the raw base64 string to disk is not playable audio.
Speaker must match modelThe mismatch fails both ways: a v3 short name on bulbul:v4-flash and a v4 persona on bulbul:v3 both return 400. Pair model and speaker explicitly.
No SSMLSSML markup is NOT supported. Use pace (and on v4, pitch / loudness) plus sentence-boundary chunking.
Use native scriptRomanized Indic input ("Aapka order confirm ho gaya hai") degrades quality. Write Indic words in native script; keep English loanwords in Latin ("आपका order confirm हो गया है"). With enable_preprocessing=true, do not hand-expand numbers, dates, or currency.
ml-IN / od-IN have no v4 personasCodes are accepted. The catalog has no Malayalam or Odia IDs. Use bulbul:v3 for those languages.
Pronunciation dictionaryPass dict_id on v4-flash the same way as v3 (10 dicts/user, 100 words/dict). Create via Python client.pronunciation_dictionary.create(file=f). JS SDK upload is broken (missing multipart Content-Type) — use raw fetch + FormData with an explicit Blob type. The pronunciation-page limits row that says “v3 only” is stale; the examples on that page send dict_id with bulbul:v4-flash.

Full Docs

Fetch the voice catalog, ranked picks, streaming protocol, and codec options from:

常见问题

Text To Speech AI 技能有什么作用?

Write correct Sarvam Bulbul TTS code — bulbul:v4-flash persona speaker IDs (voice_language_style), REST, HTTP stream, WebSocket, pronunciation dictionaries, and v3/v4 traps (short names rejected on v4, param ranges). Use this skill when generating speech in an app with Python or JS/TS. For live TTS in chat via MCP, use sarvam-mcp instead.

为什么在 TypingMind 中使用 Text To Speech?

因为您只需安装一次,就能搭配任何模型使用。Text To Speech 采用纯 Markdown 格式,而非特定提供商专用的代码,因此同一技能可用于 GPT-5、Claude、Gemini、Grok 或本地模型。您甚至可以在聊天中途切换模型,而不会影响技能的正常使用。TypingMind 使用您自己的 API 密钥,因此您直接向提供商付费,而不是按席位订阅;您的技能和聊天记录也都保留在您自己的存储空间中。

如何在 TypingMind 中安装 Text To Speech?

在 TypingMind 中打开“插件 → 技能 → 从 GitHub 安装”,然后粘贴 https://github.com/sarvamai/skills/tree/main/text-to-speech。TypingMind 会读取其中的 SKILL.md,并将其安装为技能,供您在各个聊天中按需启用。

哪些 AI 模型可以使用 Text To Speech?

您在 TypingMind 中连接的任何模型都可以。AI 技能采用纯 Markdown 指令,而非特定提供商专用的代码,因此 GPT、Claude、Gemini、Grok 和本地模型都能在请求匹配时加载此技能。

Text To Speech 可以搭配多少个 AI 模型使用?

数量不限。只要模型支持技能,您就可以将它与 Text To Speech 搭配使用。GPT、Claude、Gemini、Grok、DeepSeek、Mistral、Llama 等模型都可以通过您自己的 API 密钥接入 TypingMind。

Text To Speech AI 技能免费吗?

是的。sarvamai 已在 GitHub 上根据 Apache-2.0 许可证发布了该技能。您只需向自己的 AI 提供商支付所用 Token 的费用。

什么是 AI 技能?

AI 技能是一组可复用的指令,用于教会 AI 模型完成某项特定任务。它遵循开放的 Agent Skills 格式:包含名称和描述的 SKILL.md 文件,以及模型可能需要的脚本、模板或参考文件。模型仅在您的请求与技能匹配时才会读取这些指令,因此已安装的技能在使用前不会产生任何费用。

AI 技能与插件或 MCP 服务器有何不同?

插件或 MCP 服务器为模型提供可调用的新工具,也就是在某处运行并返回结果的代码。AI 技能则为模型提供知识和流程:如何处理任务、遵循哪些步骤,以及怎样的输出才算优质。技能采用纯 Markdown 格式,因此不需要服务器、API 密钥或运行时环境,并且适用于任何模型。

查看全部

立即创建您自己的 AI 工作区

订阅我们的电子简报,获取新功能和后续赠奖活动的通知 👇