Skip to main content
The official C/C++ library for the Typecast API. Convert text to lifelike speech using AI-powered voices. Compatible with C11 and later versions. Works with CMake, manual compilation, and supports cross-platform development including Windows, Linux, macOS, and embedded systems.

Source Code

Typecast C SDK Source Code

API Documentation

Typecast API Documentation

Requirements

  • CMake 3.14+
  • libcurl (with SSL support)
  • C11 compatible compiler

Installation

Latest registered version: v1.2.7 in the SDK Git tags.

Build Options

Quick Start

Features

The Typecast C/C++ SDK provides powerful features for text-to-speech conversion:
  • C and C++ Support: Pure C API with optional C++ wrapper for convenience
  • Multiple Voice Models: Support for ssfm-v30 (latest) and ssfm-v21 AI voice models
  • Multi-language Support: 37 languages including English, Korean, Spanish, Japanese, Chinese, and more
  • Emotion Control: Preset emotions (normal, happy, sad, angry, whisper, toneup, tonedown) or smart context-aware inference
  • Audio Customization: Control loudness (LUFS -70 to 0), pitch (-12 to +12 semitones), tempo (0.5x to 2.0x), and format (WAV/MP3)
  • Voice Discovery: V2 Voices API with filtering by model, gender, age, and use cases
  • Instant Voice Cloning: Upload a WAV/MP3 sample and create a custom voice ID
  • Cross-Platform: Windows, Linux, macOS, ARM (32/64-bit) support
  • Embedded Ready: Optimized for minimal footprint, cross-compilation support
  • Timestamp TTS: Word- and character-level alignment data for subtitles, karaoke, and lip-sync
  • Unreal Engine Ready: Designed for easy integration with game engines
  • Streaming: Real-time chunked audio delivery for low-latency playback

Voice Recommendations

Use typecast_recommend_voices when you know the desired style but not the exact voice_id.
Recommendation results contain only voice_id, voice_name, and score. Use typecast_get_voice or typecast_get_voices when you need detailed metadata such as supported models, emotions, gender, age, or use cases.

Configuration

Set your API key via environment variable or constructor:
When requests go through your own proxy, pass the proxy host and omit the API key by passing NULL or an empty string. The SDK will not send the X-API-KEY header for empty or missing keys. Requests to the default Typecast host still require an API key.
Proxy without API key

Advanced Usage

Emotion Control (ssfm-v30)

ssfm-v30 offers two emotion control modes: Preset and Smart.
Let the AI infer emotion from context:

Audio Customization

Control loudness, pitch, tempo, and output format:

Generate audio to a file

Use typecast_generate_to_file when you want the SDK to synthesize speech and write the audio bytes directly to a local file. The model defaults to ssfm-v30, and .mp3 / .wav extensions infer the output format when no output format is set. Browse available voice IDs on the Voices page.
For C++ wrapper users:

Text pauses

Use text pause markup when you only need silent gaps inside one composed text segment. Put <|5s|>, <|1s|>, <|0.3s|>, or <|0.34413s|> directly in the text. The value is interpreted as seconds and must end with s. This keeps the pause expression visible in plain text without adding separate pause calls.

Multi-speaker composition

Use the composer chaining API when one output file needs different voices or per-segment options such as pitch, tempo, prompt, or seed. The composer generates each segment as WAV, trims leading/trailing silent PCM samples, and concatenates the result. If you need MP3, generate WAV first and convert it in your app or server pipeline.

Voice Discovery (V2 API)

List and filter available voices with enhanced metadata:

Multilingual Content

The SDK supports 37 languages with automatic language detection:

Streaming

Stream audio chunks in real-time for low-latency playback:
WAV streaming format: 32000 Hz, 16-bit, mono PCM. The first chunk includes a 44-byte WAV header (size = 0xFFFFFFFF); subsequent chunks are raw PCM only. For MP3: 320 kbps, 44100 Hz, each chunk is independently decodable. Use TYPECAST_OUTPUT_STREAM_DEFAULT() for safe output defaults.

Timestamp TTS

typecast_text_to_speech_with_timestamps() wraps POST /v1/text-to-speech/with-timestamps and returns the audio together with per-word and per-character alignment data — useful for karaoke highlights, subtitle generation, and lip-sync applications.

Basic Usage

Granularity

Set request.granularity = TYPECAST_GRANULARITY_WORD (default) or TYPECAST_GRANULARITY_CHAR to control the alignment unit.

Subtitle Export

Japanese / Chinese: Word-level segmentation is not meaningful for languages without whitespace delimiters (jpn, zho). Use TYPECAST_GRANULARITY_CHAR for these languages to get character-level alignment.

Instant Voice Cloning

Clone a custom voice from a short audio sample, then pass the returned uc_ voice ID directly to TTS.
Voice cloning audio must be 25 MB or smaller, the audio duration must be 5-150 seconds, and the custom voice name must be 1-30 characters.

Supported Languages

The SDK supports 37 languages with automatic language detection:
If not specified, the language will be automatically detected from the input text.

Error Handling

The SDK provides specific error codes for handling API errors:

Error Codes

C++ Wrapper

For C++ projects, enable the optional C++ wrapper for a more idiomatic interface:

Platform Support

The SDK has been verified through automated E2E testing on the following platforms:

Embedded Systems

This SDK can be integrated into embedded systems with network connectivity.

Cross-Compilation

Memory Requirements

Unreal Engine Integration

This SDK is designed for seamless integration with Unreal Engine 4.27+ and Unreal Engine 5.x.
1

Build the SDK

Build as a static library:
2

Create Plugin Structure

Create a plugin in your Unreal project:
3

Configure Build.cs

Add library linking to your Build.cs:
For complete Unreal Engine integration guide including Blueprint support and audio playback, see the README in the SDK repository.

API Reference

Client Functions

Text-to-Speech Functions

Voice Functions

Utility Functions

TypecastTTSRequest Fields

TypecastTTSResponse Fields