Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Log how long each transcription step takes and use the normal toasts in its settings

Barnabas8f45559e3064
diff --git a/lib/screens/transcription_settings_screen.dart b/lib/screens/transcription_settings_screen.dart
index 2c6866c6..afc0b802 100644
--- a/lib/screens/transcription_settings_screen.dart
+++ b/lib/screens/transcription_settings_screen.dart
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../l10n/app_localizations.dart';
import '../services/player_settings.dart';
import '../services/transcription_service.dart';
+import '../widgets/overlay_toast.dart';
/// Advanced > Bookmark transcription settings: opt-in toggle and on-device
/// Whisper model management (download / pick / delete). Everything here runs
@@ -71,10 +72,8 @@ class _TranscriptionSettingsScreenState
// Refresh in case a partial file was left behind.
_downloaded[size] = await TranscriptionService.instance.isModelDownloaded(size);
if (!mounted) return;
- ScaffoldMessenger.of(context).showSnackBar(SnackBar(
- content: Text(l.transcriptionDownloadFailed),
- behavior: SnackBarBehavior.floating,
- ));
+ showOverlayToast(context, l.transcriptionDownloadFailed,
+ icon: Icons.error_outline_rounded);
}
}
}
diff --git a/lib/services/transcription_service.dart b/lib/services/transcription_service.dart
index 63255183..388dd5e4 100644
--- a/lib/services/transcription_service.dart
+++ b/lib/services/transcription_service.dart
@@ -265,12 +265,14 @@ class TranscriptionService {
_busy = true;
String? wavPath;
+ final watch = Stopwatch()..start();
try {
wavPath = await _extractWav(
sourcePath: sourcePath,
startSeconds: localOffset,
durationSeconds: window,
);
+ final extractMs = watch.elapsedMilliseconds;
if (wavPath == null || !File(wavPath).existsSync()) {
throw TranscriptionException(TranscriptionError.extractFailed);
}
@@ -298,6 +300,10 @@ class TranscriptionService {
if (e is TranscriptionException) rethrow;
throw TranscriptionException(TranscriptionError.transcribeFailed, e);
}
+ debugPrint('[Transcribe] window=${window.toStringAsFixed(1)}s '
+ 'model=${info.fileName} extract=${extractMs}ms '
+ 'whisper=${watch.elapsedMilliseconds - extractMs}ms '
+ 'chars=${text.length}');
if (text.isEmpty) throw TranscriptionException(TranscriptionError.empty);
// Hand the extracted clip to the caller (for review playback). Ownership
// transfers, so null out wavPath to skip the finally-delete below.