Skip to content
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions lib/controllers/whisper_transcription_controller.dart
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the loop logic to like it was before, much simpler. No need to keep a count of the segments. Just use a boolean to check whether some part has failed.

Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:ffmpeg_kit_flutter_new/return_code.dart';
import 'package:get/get.dart';
import 'package:path_provider/path_provider.dart';
import 'package:resonate/utils/constants.dart';
import 'package:resonate/utils/enums/log_type.dart';
import 'package:resonate/views/widgets/snackbar.dart';
import 'package:whisper_flutter_new/whisper_flutter_new.dart';

class WhisperTranscriptionController extends GetxController {
Expand Down Expand Up @@ -59,6 +61,9 @@ class WhisperTranscriptionController extends GetxController {
final StringBuffer lrcContent = StringBuffer();
lrcContent.writeln('[re:Resonate App - AOSSIE]');
lrcContent.writeln('[ve:v1.0.0]');

bool hasFailedSegments = false;

for (WhisperTranscribeSegment? segment in transcriptionSegments) {
try {
// Parse the log line
Expand All @@ -67,11 +72,25 @@ class WhisperTranscriptionController extends GetxController {
// Convert to LRC format and add to content
lrcContent.writeln(segmentString);
}
} catch (e) {
print(e.toString());
} catch (e, stackTrace) {
log(
'Error converting transcription segment: ${e.toString()}',
error: e,
stackTrace: stackTrace,
);
hasFailedSegments = true;
}
}

// Show a single user-friendly snackbar if any segments failed
if (hasFailedSegments) {
customSnackbar(
'Transcription Warning',
'Some parts of the transcription could not be processed.',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localize the snackbar text

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! Snackbar text is now localized

LogType.warning,
);
}

return lrcContent.toString();
}

Expand Down