TextToSpeechService (services/text_to_speech_service.dart)

flutterclaw · lib/services/text_to_speech_service.dart · dart · MIT
voice

Provides a simple API to synthesize text to speech or audio files using the device's native TTS engine, without external API keys.

// Source: https://github.com/flutterclaw/flutterclaw | License: MIT | Copyright 2026 Franco Rapetti
// Provided via justclaw.it.com; keep this notice with the code.
/// Text-to-speech service using the system TTS engine (flutter_tts).
///
/// Wraps [FlutterTts] to provide a simple API for synthesizing text to an
/// audio file or for direct speech playback. Uses the platform's built-in
/// voices — no API key required.
library;

import 'dart:async';
import 'dart:io';

import 'package:flutter_tts/flutter_tts.dart';
import 'package:logging/logging.dart';
import 'package:path_provider/path_provider.dart';

final _log = Logger('TextToSpeechService');

class TextToSpeechService {
  final FlutterTts _tts = FlutterTts();
  bool _initialized = false;
  bool _isSpeaking = false;
  bool _synthesizi

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key