Logo Text To Speech

Text To Speech

Tổ chức
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

Tổng quan

Nhà phát hànhsarvamai
Kho mãskills
Tên kỹ năngtext-to-speech
Sao
72
Bản fork
24
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được sarvamai công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Text To Speech trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/sarvamai/skills/tree/main/text-to-speech
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

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
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Text To Speech trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Text To Speech ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Text To Speech với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

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:

Câu hỏi thường gặp

Kỹ năng AI Text To Speech làm được gì?

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.

Vì sao nên dùng Text To Speech trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Text To Speech là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Text To Speech trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/sarvamai/skills/tree/main/text-to-speech. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Text To Speech?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Text To Speech với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Text To Speech với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Text To Speech có miễn phí không?

Có. Kỹ năng này được sarvamai phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇