- Mise à jour de la version de l'application à `1.1.17` dans `app_version.dart` et `version.json`. - Création d'un module complet de statistiques (`EventStatisticsPage`, `EventStatisticsService`, `EventStatisticsTab`) permettant de filtrer et visualiser les KPI d'événements (montants HT/TTC, panier moyen, répartition par type, top options). - Ajout d'une entrée "Statistiques événements" dans le menu latéral (`MainDrawer`) protégée par la permission `generate_reports`. - Migration exclusive vers Google Cloud TTS dans `SmartTextToSpeechService` et suppression de `TextToSpeechService` (Web Speech API native) pour garantir une compatibilité maximale sur tous les navigateurs. - Mise à jour des dépendances dans `pubspec.yaml` (`google_fonts`, `flutter_secure_storage`, `mobile_scanner`, `flutter_local_notifications`). - Migration du code d'export ICS vers `package:web` pour remplacer l'utilisation de `dart:html` obsolète. - Mise à jour du `CHANGELOG.md` documentant les statistiques et l'évolution du service de synthèse vocale.
79 lines
2.2 KiB
Dart
79 lines
2.2 KiB
Dart
import 'package:em2rp/services/cloud_text_to_speech_service.dart';
|
|
import 'package:em2rp/utils/debug_log.dart';
|
|
|
|
/// Service de synthèse vocale utilisant exclusivement Google Cloud TTS
|
|
/// Garantit une qualité et une compatibilité maximales sur tous les navigateurs
|
|
class SmartTextToSpeechService {
|
|
static bool _initialized = false;
|
|
|
|
/// Initialiser le service
|
|
static Future<void> initialize() async {
|
|
if (_initialized) return;
|
|
|
|
try {
|
|
DebugLog.info('[SmartTTS] Initializing Cloud TTS only...');
|
|
|
|
// Pré-charger les phrases courantes pour Cloud TTS
|
|
Future.delayed(const Duration(milliseconds: 500), () {
|
|
CloudTextToSpeechService.preloadCommonPhrases();
|
|
});
|
|
|
|
_initialized = true;
|
|
DebugLog.info('[SmartTTS] ✓ Initialized (Cloud TTS only)');
|
|
} catch (e) {
|
|
DebugLog.error('[SmartTTS] Initialization error', e);
|
|
_initialized = true; // Continuer quand même
|
|
}
|
|
}
|
|
|
|
/// Lire un texte à haute voix avec Google Cloud TTS
|
|
static Future<void> speak(String text) async {
|
|
if (!_initialized) {
|
|
await initialize();
|
|
}
|
|
|
|
try {
|
|
DebugLog.info('[SmartTTS] → Using Cloud TTS');
|
|
await CloudTextToSpeechService.speak(text);
|
|
DebugLog.info('[SmartTTS] ✓ Cloud TTS succeeded');
|
|
} catch (e) {
|
|
DebugLog.error('[SmartTTS] ✗ Cloud TTS failed', e);
|
|
rethrow;
|
|
}
|
|
}
|
|
|
|
/// Arrêter toute lecture en cours
|
|
static Future<void> stop() async {
|
|
try {
|
|
CloudTextToSpeechService.stopAll();
|
|
} catch (e) {
|
|
DebugLog.error('[SmartTTS] Error stopping', e);
|
|
}
|
|
}
|
|
|
|
/// Vérifier si une lecture est en cours
|
|
static Future<bool> isSpeaking() async {
|
|
// Cloud TTS n'a pas de méthode native pour vérifier le statut
|
|
// Retourner false par défaut (peut être amélioré si nécessaire)
|
|
return false;
|
|
}
|
|
|
|
/// Obtenir le statut actuel
|
|
static Map<String, dynamic> getStatus() {
|
|
return {
|
|
'initialized': _initialized,
|
|
'currentStrategy': 'Cloud TTS (exclusive)',
|
|
};
|
|
}
|
|
|
|
/// Nettoyer les ressources
|
|
static Future<void> dispose() async {
|
|
try {
|
|
CloudTextToSpeechService.clearCache();
|
|
} catch (e) {
|
|
DebugLog.error('[SmartTTS] Error disposing', e);
|
|
}
|
|
}
|
|
}
|
|
|