Add constructor fromPtr() for all flutter class with factory ctor. (#1667)

Co-authored-by: wangrui <wangrui@oecore.com>
This commit is contained in:
w-rui
2024-12-31 18:07:52 +08:00
committed by GitHub
parent ebe92e523d
commit 0a43e9c879
9 changed files with 23 additions and 0 deletions

View File

@@ -62,6 +62,8 @@ class AudioEvent {
} }
class AudioTagging { class AudioTagging {
AudioTagging.fromPtr({required this.ptr, required this.config});
AudioTagging._({required this.ptr, required this.config}); AudioTagging._({required this.ptr, required this.config});
// The user has to invoke AudioTagging.free() to avoid memory leak. // The user has to invoke AudioTagging.free() to avoid memory leak.

View File

@@ -53,6 +53,8 @@ class KeywordResult {
} }
class KeywordSpotter { class KeywordSpotter {
KeywordSpotter.fromPtr({required this.ptr, required this.config});
KeywordSpotter._({required this.ptr, required this.config}); KeywordSpotter._({required this.ptr, required this.config});
/// The user is responsible to call the OnlineRecognizer.free() /// The user is responsible to call the OnlineRecognizer.free()

View File

@@ -227,6 +227,8 @@ class OfflineRecognizerResult {
} }
class OfflineRecognizer { class OfflineRecognizer {
OfflineRecognizer.fromPtr({required this.ptr, required this.config});
OfflineRecognizer._({required this.ptr, required this.config}); OfflineRecognizer._({required this.ptr, required this.config});
void free() { void free() {

View File

@@ -94,6 +94,9 @@ class OfflineSpeakerDiarizationConfig {
} }
class OfflineSpeakerDiarization { class OfflineSpeakerDiarization {
OfflineSpeakerDiarization.fromPtr(
{required this.ptr, required this.config, required this.sampleRate});
OfflineSpeakerDiarization._( OfflineSpeakerDiarization._(
{required this.ptr, required this.config, required this.sampleRate}); {required this.ptr, required this.config, required this.sampleRate});

View File

@@ -162,6 +162,8 @@ class OnlineRecognizerResult {
} }
class OnlineRecognizer { class OnlineRecognizer {
OnlineRecognizer.fromPtr({required this.ptr, required this.config});
OnlineRecognizer._({required this.ptr, required this.config}); OnlineRecognizer._({required this.ptr, required this.config});
/// The user is responsible to call the OnlineRecognizer.free() /// The user is responsible to call the OnlineRecognizer.free()

View File

@@ -36,6 +36,8 @@ class OfflinePunctuationConfig {
} }
class OfflinePunctuation { class OfflinePunctuation {
OfflinePunctuation.fromPtr({required this.ptr, required this.config});
OfflinePunctuation._({required this.ptr, required this.config}); OfflinePunctuation._({required this.ptr, required this.config});
// The user has to invoke OfflinePunctuation.free() to avoid memory leak. // The user has to invoke OfflinePunctuation.free() to avoid memory leak.

View File

@@ -25,6 +25,8 @@ class SpeakerEmbeddingExtractorConfig {
} }
class SpeakerEmbeddingExtractor { class SpeakerEmbeddingExtractor {
SpeakerEmbeddingExtractor.fromPtr({required this.ptr, required this.dim});
SpeakerEmbeddingExtractor._({required this.ptr, required this.dim}); SpeakerEmbeddingExtractor._({required this.ptr, required this.dim});
/// The user is responsible to call the SpeakerEmbeddingExtractor.free() /// The user is responsible to call the SpeakerEmbeddingExtractor.free()
@@ -101,6 +103,8 @@ class SpeakerEmbeddingExtractor {
} }
class SpeakerEmbeddingManager { class SpeakerEmbeddingManager {
SpeakerEmbeddingManager.fromPtr({required this.ptr, required this.dim});
SpeakerEmbeddingManager._({required this.ptr, required this.dim}); SpeakerEmbeddingManager._({required this.ptr, required this.dim});
// The user has to use SpeakerEmbeddingManager.free() to avoid memory leak // The user has to use SpeakerEmbeddingManager.free() to avoid memory leak

View File

@@ -82,6 +82,8 @@ class GeneratedAudio {
} }
class OfflineTts { class OfflineTts {
OfflineTts.fromPtr({required this.ptr, required this.config});
OfflineTts._({required this.ptr, required this.config}); OfflineTts._({required this.ptr, required this.config});
/// The user is responsible to call the OfflineTts.free() /// The user is responsible to call the OfflineTts.free()

View File

@@ -54,6 +54,8 @@ class SpeechSegment {
} }
class CircularBuffer { class CircularBuffer {
CircularBuffer.fromPtr({required this.ptr});
CircularBuffer._({required this.ptr}); CircularBuffer._({required this.ptr});
/// The user has to invoke CircularBuffer.free() on the returned instance /// The user has to invoke CircularBuffer.free() on the returned instance
@@ -115,6 +117,8 @@ class CircularBuffer {
} }
class VoiceActivityDetector { class VoiceActivityDetector {
VoiceActivityDetector.fromPtr({required this.ptr, required this.config});
VoiceActivityDetector._({required this.ptr, required this.config}); VoiceActivityDetector._({required this.ptr, required this.config});
// The user has to invoke VoiceActivityDetector.free() to avoid memory leak. // The user has to invoke VoiceActivityDetector.free() to avoid memory leak.