Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion lib/controllers/whisper_transcription_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import 'package:ffmpeg_kit_flutter_new/ffmpeg_kit.dart';
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:whisper_flutter_new/whisper_flutter_new.dart';

class WhisperTranscriptionController extends GetxController {
final Whisper whisper = Whisper(
model: WhisperModel.base,
model: currentWhisperModel.value,
downloadHost: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main",
);
Comment on lines 11 to 14
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Whisper model changes won't take effect until controller is recreated.

The Whisper instance is initialized once with currentWhisperModel.value at construction time. If a user changes the Whisper model preference in the App Preferences screen, the change won't take effect for this controller until the app restarts or the controller is recreated.

Consider one of these approaches:

Solution 1: Make Whisper instance reactive (preferred if whisper_flutter_new supports it):

 class WhisperTranscriptionController extends GetxController {
-  final Whisper whisper = Whisper(
-    model: currentWhisperModel.value,
-    downloadHost: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main",
-  );
+  late Whisper whisper;
+  
+  @override
+  void onInit() {
+    super.onInit();
+    _initWhisper();
+    ever(currentWhisperModel, (_) => _initWhisper());
+  }
+  
+  void _initWhisper() {
+    whisper = Whisper(
+      model: currentWhisperModel.value,
+      downloadHost: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main",
+    );
+  }

Solution 2: Recreate on each transcription (simpler but may have performance implications):

 class WhisperTranscriptionController extends GetxController {
-  final Whisper whisper = Whisper(
+  Whisper _createWhisper() => Whisper(
     model: currentWhisperModel.value,
     downloadHost: "https://huggingface.co/ggerganov/whisper.cpp/resolve/main",
   );

   Future<String> transcribeChapter(String chapterId) async {
     log('Starting to Transcribe');
     final convertResult = await convertMp4ToWav(chapterId);
     if (convertResult) {
       final storagePath = await getApplicationDocumentsDirectory();
+      final whisper = _createWhisper();
       final transcription = await whisper.transcribe(
🤖 Prompt for AI Agents
In lib/controllers/whisper_transcription_controller.dart around lines 11 to 14,
the Whisper instance is created once with currentWhisperModel.value so changes
to the preference won't take effect; fix by making the Whisper client follow the
reactive model or by recreating it when needed: either (preferred) track
currentWhisperModel changes (add a listener/obx/reactive binding) and
rebuild/reassign the Whisper instance whenever the model value changes
(dispose/close the old instance if required), or (simpler) remove the long-lived
Whisper field and instantiate a new Whisper with the currentWhisperModel.value
each time you start a transcription (ensuring any streaming/cleanup is handled
to avoid leaks); choose one approach and implement proper disposal/exception
handling.


Expand Down
64 changes: 64 additions & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,70 @@
"@contribute": {
"description": "Label for a section encouraging users to contribute to the project."
},
"appPreferences": "App Preferences",
"@appPreferences": {
"description": "Label for the app preferences settings page."
},
"transcriptionModel": "Transcription Model",
"@transcriptionModel": {
"description": "Section title for choosing AI transcription model."
},
"transcriptionModelDescription": "Choose the AI model for voice transcription. Larger models are more accurate but slower and require more storage.",
"@transcriptionModelDescription": {
"description": "Description text explaining transcription model choices."
},
"whisperModelTiny": "Tiny",
"@whisperModelTiny": {
"description": "Name of the smallest Whisper AI model."
},
"whisperModelTinyDescription": "Fastest, least accurate (~39 MB)",
"@whisperModelTinyDescription": {
"description": "Description of the Tiny Whisper model performance and size."
},
"whisperModelBase": "Base",
"@whisperModelBase": {
"description": "Name of the base Whisper AI model."
},
"whisperModelBaseDescription": "Balanced speed and accuracy (~74 MB)",
"@whisperModelBaseDescription": {
"description": "Description of the Base Whisper model performance and size."
},
"whisperModelSmall": "Small",
"@whisperModelSmall": {
"description": "Name of the small Whisper AI model."
},
"whisperModelSmallDescription": "Good accuracy, slower (~244 MB)",
"@whisperModelSmallDescription": {
"description": "Description of the Small Whisper model performance and size."
},
"whisperModelMedium": "Medium",
"@whisperModelMedium": {
"description": "Name of the medium Whisper AI model."
},
"whisperModelMediumDescription": "High accuracy, slower (~769 MB)",
"@whisperModelMediumDescription": {
"description": "Description of the Medium Whisper model performance and size."
},
"whisperModelLargeV1": "Large V1",
"@whisperModelLargeV1": {
"description": "Name of the large V1 Whisper AI model."
},
"whisperModelLargeV1Description": "Most accurate, slowest (~1.55 GB)",
"@whisperModelLargeV1Description": {
"description": "Description of the Large V1 Whisper model performance and size."
},
"whisperModelLargeV2": "Large V2",
"@whisperModelLargeV2": {
"description": "Name of the large V2 Whisper AI model."
},
"whisperModelLargeV2Description": "Improved large model with higher accuracy (~1.55 GB)",
"@whisperModelLargeV2Description": {
"description": "Description of the Large V2 Whisper model performance and size."
},
"modelDownloadInfo": "Models are downloaded when first used. We recommend using Base, Small, or Medium. Large models require very high-end devices.",
"@modelDownloadInfo": {
"description": "Information message about model download."
},
"logOut": "Log out",
"@logOut": {
"description": "Button text to log the user out of their account."
Expand Down
64 changes: 64 additions & 0 deletions lib/l10n/app_hi.arb
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,70 @@
"@contribute": {
"description": "Label for a section encouraging users to contribute to the project."
},
"appPreferences": "ऐप प्राथमिकताएं",
"@appPreferences": {
"description": "Label for the app preferences settings page."
},
"transcriptionModel": "ट्रांसक्रिप्शन मॉडल",
"@transcriptionModel": {
"description": "Section title for choosing AI transcription model."
},
"transcriptionModelDescription": "वॉयस ट्रांसक्रिप्शन के लिए AI मॉडल चुनें। बड़े मॉडल अधिक सटीक हैं लेकिन धीमे हैं और अधिक स्टोरेज की आवश्यकता होती है।",
"@transcriptionModelDescription": {
"description": "Description text explaining transcription model choices."
},
"whisperModelTiny": "टाइनी",
"@whisperModelTiny": {
"description": "Name of the smallest Whisper AI model."
},
"whisperModelTinyDescription": "सबसे तेज़, कम सटीक (~39 MB)",
"@whisperModelTinyDescription": {
"description": "Description of the Tiny Whisper model performance and size."
},
"whisperModelBase": "बेस",
"@whisperModelBase": {
"description": "Name of the base Whisper AI model."
},
"whisperModelBaseDescription": "संतुलित गति और सटीकता (~74 MB)",
"@whisperModelBaseDescription": {
"description": "Description of the Base Whisper model performance and size."
},
"whisperModelSmall": "स्मॉल",
"@whisperModelSmall": {
"description": "Name of the small Whisper AI model."
},
"whisperModelSmallDescription": "अच्छी सटीकता, धीमा (~244 MB)",
"@whisperModelSmallDescription": {
"description": "Description of the Small Whisper model performance and size."
},
"whisperModelMedium": "मीडियम",
"@whisperModelMedium": {
"description": "Name of the medium Whisper AI model."
},
"whisperModelMediumDescription": "उच्च सटीकता, धीमा (~769 MB)",
"@whisperModelMediumDescription": {
"description": "Description of the Medium Whisper model performance and size."
},
"whisperModelLargeV1": "लार्ज V1",
"@whisperModelLargeV1": {
"description": "Name of the large V1 Whisper AI model."
},
"whisperModelLargeV1Description": "सबसे अधिक सटीक, सबसे धीमा (~1.55 GB)",
"@whisperModelLargeV1Description": {
"description": "Description of the Large V1 Whisper model performance and size."
},
"whisperModelLargeV2": "लार्ज V2",
"@whisperModelLargeV2": {
"description": "Name of the large V2 Whisper AI model."
},
"whisperModelLargeV2Description": "उच्च सटीकता के साथ बेहतर बड़ा मॉडल (~1.55 GB)",
"@whisperModelLargeV2Description": {
"description": "Description of the Large V2 Whisper model performance and size."
},
"modelDownloadInfo": "मॉडल पहली बार उपयोग करने पर डाउनलोड हो जाते हैं। हम बेस, स्मॉल या मीडियम का उपयोग करने की सिफारिश करते हैं। बड़े मॉडल के लिए बहुत उच्च अंत उपकरणों की आवश्यकता होती है।",
"@modelDownloadInfo": {
"description": "Information message about model download."
},
"logOut": "लॉग आउट",
"@logOut": {
"description": "Button text to log the user out of their account."
Expand Down
96 changes: 96 additions & 0 deletions lib/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,102 @@ abstract class AppLocalizations {
/// **'Contribute'**
String get contribute;

/// Label for the app preferences settings page.
///
/// In en, this message translates to:
/// **'App Preferences'**
String get appPreferences;

/// Section title for choosing AI transcription model.
///
/// In en, this message translates to:
/// **'Transcription Model'**
String get transcriptionModel;

/// Description text explaining transcription model choices.
///
/// In en, this message translates to:
/// **'Choose the AI model for voice transcription. Larger models are more accurate but slower and require more storage.'**
String get transcriptionModelDescription;

/// Name of the smallest Whisper AI model.
///
/// In en, this message translates to:
/// **'Tiny'**
String get whisperModelTiny;

/// Description of the Tiny Whisper model performance and size.
///
/// In en, this message translates to:
/// **'Fastest, least accurate (~39 MB)'**
String get whisperModelTinyDescription;

/// Name of the base Whisper AI model.
///
/// In en, this message translates to:
/// **'Base'**
String get whisperModelBase;

/// Description of the Base Whisper model performance and size.
///
/// In en, this message translates to:
/// **'Balanced speed and accuracy (~74 MB)'**
String get whisperModelBaseDescription;

/// Name of the small Whisper AI model.
///
/// In en, this message translates to:
/// **'Small'**
String get whisperModelSmall;

/// Description of the Small Whisper model performance and size.
///
/// In en, this message translates to:
/// **'Good accuracy, slower (~244 MB)'**
String get whisperModelSmallDescription;

/// Name of the medium Whisper AI model.
///
/// In en, this message translates to:
/// **'Medium'**
String get whisperModelMedium;

/// Description of the Medium Whisper model performance and size.
///
/// In en, this message translates to:
/// **'High accuracy, slower (~769 MB)'**
String get whisperModelMediumDescription;

/// Name of the large V1 Whisper AI model.
///
/// In en, this message translates to:
/// **'Large V1'**
String get whisperModelLargeV1;

/// Description of the Large V1 Whisper model performance and size.
///
/// In en, this message translates to:
/// **'Most accurate, slowest (~1.55 GB)'**
String get whisperModelLargeV1Description;

/// Name of the large V2 Whisper AI model.
///
/// In en, this message translates to:
/// **'Large V2'**
String get whisperModelLargeV2;

/// Description of the Large V2 Whisper model performance and size.
///
/// In en, this message translates to:
/// **'Improved large model with higher accuracy (~1.55 GB)'**
String get whisperModelLargeV2Description;

/// Information message about model download.
///
/// In en, this message translates to:
/// **'Models are downloaded when first used. We recommend using Base, Small, or Medium. Large models require very high-end devices.'**
String get modelDownloadInfo;

/// Button text to log the user out of their account.
///
/// In en, this message translates to:
Expand Down
53 changes: 53 additions & 0 deletions lib/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,59 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get contribute => 'Contribute';

@override
String get appPreferences => 'App Preferences';

@override
String get transcriptionModel => 'Transcription Model';

@override
String get transcriptionModelDescription =>
'Choose the AI model for voice transcription. Larger models are more accurate but slower and require more storage.';

@override
String get whisperModelTiny => 'Tiny';

@override
String get whisperModelTinyDescription => 'Fastest, least accurate (~39 MB)';

@override
String get whisperModelBase => 'Base';

@override
String get whisperModelBaseDescription =>
'Balanced speed and accuracy (~74 MB)';

@override
String get whisperModelSmall => 'Small';

@override
String get whisperModelSmallDescription => 'Good accuracy, slower (~244 MB)';

@override
String get whisperModelMedium => 'Medium';

@override
String get whisperModelMediumDescription => 'High accuracy, slower (~769 MB)';

@override
String get whisperModelLargeV1 => 'Large V1';

@override
String get whisperModelLargeV1Description =>
'Most accurate, slowest (~1.55 GB)';

@override
String get whisperModelLargeV2 => 'Large V2';

@override
String get whisperModelLargeV2Description =>
'Improved large model with higher accuracy (~1.55 GB)';

@override
String get modelDownloadInfo =>
'Models are downloaded when first used. We recommend using Base, Small, or Medium. Large models require very high-end devices.';

@override
String get logOut => 'Log out';

Expand Down
53 changes: 53 additions & 0 deletions lib/l10n/app_localizations_gu.dart
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,59 @@ class AppLocalizationsGu extends AppLocalizations {
@override
String get contribute => 'યોગદાન આપો';

@override
String get appPreferences => 'App Preferences';

@override
String get transcriptionModel => 'Transcription Model';

@override
String get transcriptionModelDescription =>
'Choose the AI model for voice transcription. Larger models are more accurate but slower and require more storage.';

@override
String get whisperModelTiny => 'Tiny';

@override
String get whisperModelTinyDescription => 'Fastest, least accurate (~39 MB)';

@override
String get whisperModelBase => 'Base';

@override
String get whisperModelBaseDescription =>
'Balanced speed and accuracy (~74 MB)';

@override
String get whisperModelSmall => 'Small';

@override
String get whisperModelSmallDescription => 'Good accuracy, slower (~244 MB)';

@override
String get whisperModelMedium => 'Medium';

@override
String get whisperModelMediumDescription => 'High accuracy, slower (~769 MB)';

@override
String get whisperModelLargeV1 => 'Large V1';

@override
String get whisperModelLargeV1Description =>
'Most accurate, slowest (~1.55 GB)';

@override
String get whisperModelLargeV2 => 'Large V2';

@override
String get whisperModelLargeV2Description =>
'Improved large model with higher accuracy (~1.55 GB)';

@override
String get modelDownloadInfo =>
'Models are downloaded when first used. We recommend using Base, Small, or Medium. Large models require very high-end devices.';

@override
String get logOut => 'લોગ આઉટ';

Expand Down
Loading