FlowSpeech Dart SDK
flowspeech is a small Dart client for the FlowSpeech text-to-speech API. It helps Dart and Flutter apps generate human-like speech audio from text, check account quota, and work with the API response metadata.
FlowSpeech supports context-aware text-to-speech generation, emotion and pause control, voice selection, and multi-speaker requests.
Installation
dependencies:
flowspeech: ^0.1.0
Then run:
dart pub get
Authentication
Create a FlowSpeech API key in your FlowSpeech account and pass it to the client:
final client = FlowSpeechClient(apiKey: 'fs_your_api_key');
For server-side Dart apps, you can also read the key from an environment variable:
final client = FlowSpeechClient.fromEnvironment();
Do not ship API keys inside public mobile, desktop, or web clients. For Flutter apps, generate audio through your own backend when the key must stay private.
Generate speech
import 'dart:io';
import 'package:flowspeech/flowspeech.dart';
Future<void> main() async {
final client = FlowSpeechClient.fromEnvironment();
final result = await client.generateSpeech(
text: 'Welcome to FlowSpeech. This audio was generated from Dart.',
voiceName: 'Kore',
);
await File('flowspeech-output.wav').writeAsBytes(result.audioBytes);
print(result.mimeType);
print(result.quota?.remaining);
client.close();
}
Multi-speaker requests
final result = await client.generateSpeech(
text: 'Speaker A: We can make this sound natural.\nSpeaker B: Great, use two voices.',
speakers: const [
FlowSpeechSpeaker(speaker: 'Speaker A', voiceName: 'Kore'),
FlowSpeechSpeaker(speaker: 'Speaker B', voiceName: 'Puck'),
],
);
Check quota
final quota = await client.checkQuota();
print('${quota.remaining} characters remaining');
API surface
This package uses the public FlowSpeech API:
GET /api/ai/text-to-speech/quotaPOST /api/ai/text-to-speech
Responses include base64 audio and metadata such as MIME type, sample rate, channel count, bit depth, and quota.
License
MIT
Libraries
- flowspeech
- Dart client for the FlowSpeech text-to-speech API.