Whisper class

A very short-lived native function.

For very short-lived functions, it is fine to call them on the main isolate. They will block the Dart execution while running the native function, so only do this for native functions which are guaranteed to be short-lived. A longer lived native function, which occupies the thread calling it.

Do not call these kind of native functions in the main isolate. They will block Dart execution. This will cause dropped frames in Flutter applications. Instead, call these native functions on a separate isolate.

Modify this to suit your own use case. Example use cases:

  1. Reuse a single isolate for various different kinds of requests.
  2. Use multiple helper isolates for parallel execution.
Annotations
  • @JsonSerializable()

Constructors

Whisper.new(dynamic model, whisper_context_params cparams, {String outputMode = "plaintext", String initMode = "late", ValueNotifier<String>? externalNotifier})
Whisper.fromJson(Map<String, dynamic> json)
factory

Properties

cparams whisper_context_params
getter/setter pair
ctx Pointer<whisper_context>
getter/setter pair
endTime int
getter/setter pair
handle int
no setter
hashCode int
The hash code for this object.
no setterinherited
initMode String
getter/setter pair
lastNSegments int
getter/setter pair
model ↔ dynamic
getter/setter pair
nNew int
getter/setter pair
outputMode String
getter/setter pair
result ValueNotifier<String>
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startTime int
getter/setter pair
timeOffset int
getter/setter pair

Methods

close() → void
free() → void
full(whisper_full_params wparams, List<double> pcmf32List) → void
fullGetSegmentsText(int i) String
fullGetSegmentT0(int i) int
fullGetSegmentT1(int i) int
fullLangId() int
fullNSegments() int
fullParallel(whisper_full_params wparams, List<double> pcmf32List, int nProcessors) → void
getSegmentCallback(Pointer<whisper_context> ctx, Pointer<whisper_state> state, int nNew, Pointer<Void> userData) → void
infer(String inputPath, {String? logPath, int numProcessors = 1, String language = "auto", bool translate = false, String initialPrompt = "", int strategy = whisper_sampling_strategy.WHISPER_SAMPLING_GREEDY, int startTime = 0, int endTime = -1, bool useOriginalTime = true, void newSegmentCallback(Pointer<whisper_context>, Pointer<whisper_state>, int, Pointer<Void>)?, Pointer<Void>? newSegmentCallbackUserData}) Future<String>
inferIsolate(String inputPath, {String? logPath, int numProcessors = 1, String language = "auto", bool translate = false, String initialPrompt = "", int strategy = whisper_sampling_strategy.WHISPER_SAMPLING_GREEDY, int startTime = 0, int endTime = -1, bool useOriginalTime = true, void newSegmentCallback(Pointer<whisper_context>, Pointer<whisper_state>, int, Pointer<Void>)?, Pointer<Void>? newSegmentCallbackUserData}) Future<String>
inferStream(String inputPath, {String? logPath, int numProcessors = 1, String language = "auto", bool translate = false, String initialPrompt = "", int startTime = 0, int endTime = -1, bool useOriginalTime = true, int strategy = whisper_sampling_strategy.WHISPER_SAMPLING_GREEDY}) ValueNotifier<String>
initModel() → void
isMultilingual() bool
langStr() String
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
output(int startSegment, int endSegment, {int timeOffset = 0}) String
printSystemInfo() String
toJson() Map<String, dynamic>
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited