mirror of
https://github.com/kuhyx/testsAndMisc.git
synced 2026-11-11 14:27:49 +01:00
Two-package monorepo: - horatio_core: pure Dart package (parser, SRS, planner) - horatio_app: Flutter UI (Bloc/Cubit, GoRouter, TTS) Features: - Script import (txt, docx, pdf) with drag-and-drop - Four script format parsers (colon, bracketed, parenthetical, screenplay) - SM-2 spaced repetition for line memorization - Rehearsal mode with TTS and line comparison - 5 bundled public domain scripts Quality: - 83 core tests + 160 app tests, both 100% branch coverage - Strict analysis (130+ lint rules, fatal-infos) - Dead code detection script (dead_code.sh) - run.sh pipeline: analyze, test, dead-code, run, web - Pre-commit hook for horatio test coverage
38 lines
869 B
Dart
38 lines
869 B
Dart
import 'package:flutter_tts/flutter_tts.dart';
|
|
|
|
/// Service for text-to-speech of cue lines during rehearsal.
|
|
class TtsService {
|
|
/// Creates a [TtsService].
|
|
TtsService() : _tts = FlutterTts();
|
|
|
|
final FlutterTts _tts;
|
|
|
|
bool _isInitialized = false;
|
|
|
|
/// Initializes TTS engine with default settings.
|
|
Future<void> initialize() async {
|
|
if (_isInitialized) return;
|
|
await _tts.setLanguage('en-US');
|
|
await _tts.setSpeechRate(0.45);
|
|
await _tts.setVolume(1);
|
|
await _tts.setPitch(1);
|
|
_isInitialized = true;
|
|
}
|
|
|
|
/// Speaks the given [text] aloud.
|
|
Future<void> speak(String text) async {
|
|
await initialize();
|
|
await _tts.speak(text);
|
|
}
|
|
|
|
/// Stops any currently playing speech.
|
|
Future<void> stop() async {
|
|
await _tts.stop();
|
|
}
|
|
|
|
/// Disposes of TTS resources.
|
|
Future<void> dispose() async {
|
|
await _tts.stop();
|
|
}
|
|
}
|