SM-AI-MODELS REST API provides simple HTTP endpoints for Text-to-Speech and Speech Recognition.
Service Ports: TTS on port
9999, ASR on port8088For streaming: See Streaming API for WebSocket and gRPC
Text-to-Speech (TTS)
Convert text to natural-sounding speech with our neural TTS engine.
Endpoint
Code
Service: SM-TTS-V1 on port 9999
Request Body
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
input | string | Yes | — | Text to synthesize (see limits for maximum length) |
voice | string | No | Yara | Voice name (Yara, Nouf, or Yara_en) |
response_format | string | No | mp3 | Audio format (mp3, wav, opus, or flac) |
speed | number | No | 1.0 | Speech speed (0.25 to 4.0) |
Available Voices
| Voice | Language | Description |
|---|---|---|
| Yara | Arabic | Female voice — Natural and clear |
| Nouf | Arabic | Female voice — Warm and expressive |
| Yara_en | English | Female voice — Professional |
Audio Formats
| Format | Content-Type | Use Case |
|---|---|---|
mp3 | audio/mpeg | Web playback, small file size |
wav | audio/wav | High quality, editing |
opus | audio/opus | Streaming, low latency |
flac | audio/flac | Lossless compression |
Examples
Basic Arabic TTS
Code
English with Custom Speed
Code
WAV Format Output
Code
Response
On success, returns binary audio data with the appropriate Content-Type header.
Error Response
Code
Handling Long Text
For text exceeding the maximum length, split it into smaller chunks:
Code
Performance Tips
Audio Format Selection
| Format | File Size | Quality | Best For |
|---|---|---|---|
| mp3 | Smallest | Good | Web playback, storage efficiency |
| opus | Small | Excellent | Streaming, low-latency apps |
| flac | Medium | Lossless | Archiving, post-processing |
| wav | Largest | Lossless | Editing, highest quality |
Speed Optimization
Code
Concurrent Requests
Code
Speech Recognition (ASR)
Convert audio to text with our high-accuracy, multi-language speech recognition engine.
Endpoint
Code
Service: SM-STT-V1 on port 8088
Request
Send audio as multipart/form-data:
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | Yes | Audio file to transcribe |
Language Support
The SM-ASR-v2 engine provides full multi-language support with high accuracy across all supported languages:
| Language | Support Level | Notes |
|---|---|---|
| Arabic | ✓ Full support | Excellent accuracy for all dialects |
| English | ✓ Full support | Native and non-native speakers |
| Other languages | ✓ Full support | Equal quality across all languages |
Key features:
- Automatic language detection
- No need to specify language in API request
- Consistent accuracy across all supported languages
- Support for mixed-language content
Supported Audio Formats
| Format | Extension | Notes |
|---|---|---|
| FLAC | .flac | Recommended for quality |
| MP3 | .mp3 | Common format |
| WAV | .wav | Uncompressed audio |
| OGG | .ogg | Open format |
| WebM | .webm | Web recordings |
Example
Code
Response
Code
Best Practices
Tips for best results:
- Audio quality: Use clear audio with minimal background noise
- Sample rate: 16kHz or higher recommended for best accuracy
- Speakers: Single speaker audio works best
- Duration: Keep audio segments under 30 seconds for optimal performance
- File size: Check API Limits for maximum file size
- Format: Use FLAC for best quality-to-size ratio
- Bit depth: 16-bit minimum, higher is better
For long recordings:
Code
Error Response
Code
Advanced ASR Endpoint
Transcribe with Diarization
For advanced transcription with speaker identification, use the /api/transcribe endpoint:
Code
Request:
Code
Response:
Code
Features:
- Speaker identification and labeling
- Word-level timestamps
- Segment-level speaker attribution
- Automatic language detection
Use Cases:
- Meeting transcriptions
- Multi-speaker conversations
- Call center analytics
Try It
Go to the API Reference to test these endpoints interactively with the API playground.
Next Steps
- Optimization & Limits — API limits and performance tuning
- Streaming API — WebSocket and gRPC for real-time audio
- cURL Examples — Comprehensive cURL examples
- gRPC Guide — Use gRPC APIs for high performance
- Error Handling — Handle errors properly
- Python Integration — Python code examples
- Node.js Integration — JavaScript/TypeScript examples
