w-rui
Committed by GitHub

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

Co-authored-by: wangrui <wangrui@oecore.com>
@@ -62,6 +62,8 @@ class AudioEvent { @@ -62,6 +62,8 @@ class AudioEvent {
62 } 62 }
63 63
64 class AudioTagging { 64 class AudioTagging {
  65 + AudioTagging.fromPtr({required this.ptr, required this.config});
  66 +
65 AudioTagging._({required this.ptr, required this.config}); 67 AudioTagging._({required this.ptr, required this.config});
66 68
67 // The user has to invoke AudioTagging.free() to avoid memory leak. 69 // The user has to invoke AudioTagging.free() to avoid memory leak.
@@ -53,6 +53,8 @@ class KeywordResult { @@ -53,6 +53,8 @@ class KeywordResult {
53 } 53 }
54 54
55 class KeywordSpotter { 55 class KeywordSpotter {
  56 + KeywordSpotter.fromPtr({required this.ptr, required this.config});
  57 +
56 KeywordSpotter._({required this.ptr, required this.config}); 58 KeywordSpotter._({required this.ptr, required this.config});
57 59
58 /// The user is responsible to call the OnlineRecognizer.free() 60 /// The user is responsible to call the OnlineRecognizer.free()
@@ -227,6 +227,8 @@ class OfflineRecognizerResult { @@ -227,6 +227,8 @@ class OfflineRecognizerResult {
227 } 227 }
228 228
229 class OfflineRecognizer { 229 class OfflineRecognizer {
  230 + OfflineRecognizer.fromPtr({required this.ptr, required this.config});
  231 +
230 OfflineRecognizer._({required this.ptr, required this.config}); 232 OfflineRecognizer._({required this.ptr, required this.config});
231 233
232 void free() { 234 void free() {
@@ -94,6 +94,9 @@ class OfflineSpeakerDiarizationConfig { @@ -94,6 +94,9 @@ class OfflineSpeakerDiarizationConfig {
94 } 94 }
95 95
96 class OfflineSpeakerDiarization { 96 class OfflineSpeakerDiarization {
  97 + OfflineSpeakerDiarization.fromPtr(
  98 + {required this.ptr, required this.config, required this.sampleRate});
  99 +
97 OfflineSpeakerDiarization._( 100 OfflineSpeakerDiarization._(
98 {required this.ptr, required this.config, required this.sampleRate}); 101 {required this.ptr, required this.config, required this.sampleRate});
99 102
@@ -162,6 +162,8 @@ class OnlineRecognizerResult { @@ -162,6 +162,8 @@ class OnlineRecognizerResult {
162 } 162 }
163 163
164 class OnlineRecognizer { 164 class OnlineRecognizer {
  165 + OnlineRecognizer.fromPtr({required this.ptr, required this.config});
  166 +
165 OnlineRecognizer._({required this.ptr, required this.config}); 167 OnlineRecognizer._({required this.ptr, required this.config});
166 168
167 /// The user is responsible to call the OnlineRecognizer.free() 169 /// The user is responsible to call the OnlineRecognizer.free()
@@ -36,6 +36,8 @@ class OfflinePunctuationConfig { @@ -36,6 +36,8 @@ class OfflinePunctuationConfig {
36 } 36 }
37 37
38 class OfflinePunctuation { 38 class OfflinePunctuation {
  39 + OfflinePunctuation.fromPtr({required this.ptr, required this.config});
  40 +
39 OfflinePunctuation._({required this.ptr, required this.config}); 41 OfflinePunctuation._({required this.ptr, required this.config});
40 42
41 // The user has to invoke OfflinePunctuation.free() to avoid memory leak. 43 // The user has to invoke OfflinePunctuation.free() to avoid memory leak.
@@ -25,6 +25,8 @@ class SpeakerEmbeddingExtractorConfig { @@ -25,6 +25,8 @@ class SpeakerEmbeddingExtractorConfig {
25 } 25 }
26 26
27 class SpeakerEmbeddingExtractor { 27 class SpeakerEmbeddingExtractor {
  28 + SpeakerEmbeddingExtractor.fromPtr({required this.ptr, required this.dim});
  29 +
28 SpeakerEmbeddingExtractor._({required this.ptr, required this.dim}); 30 SpeakerEmbeddingExtractor._({required this.ptr, required this.dim});
29 31
30 /// The user is responsible to call the SpeakerEmbeddingExtractor.free() 32 /// The user is responsible to call the SpeakerEmbeddingExtractor.free()
@@ -101,6 +103,8 @@ class SpeakerEmbeddingExtractor { @@ -101,6 +103,8 @@ class SpeakerEmbeddingExtractor {
101 } 103 }
102 104
103 class SpeakerEmbeddingManager { 105 class SpeakerEmbeddingManager {
  106 + SpeakerEmbeddingManager.fromPtr({required this.ptr, required this.dim});
  107 +
104 SpeakerEmbeddingManager._({required this.ptr, required this.dim}); 108 SpeakerEmbeddingManager._({required this.ptr, required this.dim});
105 109
106 // The user has to use SpeakerEmbeddingManager.free() to avoid memory leak 110 // The user has to use SpeakerEmbeddingManager.free() to avoid memory leak
@@ -82,6 +82,8 @@ class GeneratedAudio { @@ -82,6 +82,8 @@ class GeneratedAudio {
82 } 82 }
83 83
84 class OfflineTts { 84 class OfflineTts {
  85 + OfflineTts.fromPtr({required this.ptr, required this.config});
  86 +
85 OfflineTts._({required this.ptr, required this.config}); 87 OfflineTts._({required this.ptr, required this.config});
86 88
87 /// The user is responsible to call the OfflineTts.free() 89 /// The user is responsible to call the OfflineTts.free()
@@ -54,6 +54,8 @@ class SpeechSegment { @@ -54,6 +54,8 @@ class SpeechSegment {
54 } 54 }
55 55
56 class CircularBuffer { 56 class CircularBuffer {
  57 + CircularBuffer.fromPtr({required this.ptr});
  58 +
57 CircularBuffer._({required this.ptr}); 59 CircularBuffer._({required this.ptr});
58 60
59 /// The user has to invoke CircularBuffer.free() on the returned instance 61 /// The user has to invoke CircularBuffer.free() on the returned instance
@@ -115,6 +117,8 @@ class CircularBuffer { @@ -115,6 +117,8 @@ class CircularBuffer {
115 } 117 }
116 118
117 class VoiceActivityDetector { 119 class VoiceActivityDetector {
  120 + VoiceActivityDetector.fromPtr({required this.ptr, required this.config});
  121 +
118 VoiceActivityDetector._({required this.ptr, required this.config}); 122 VoiceActivityDetector._({required this.ptr, required this.config});
119 123
120 // The user has to invoke VoiceActivityDetector.free() to avoid memory leak. 124 // The user has to invoke VoiceActivityDetector.free() to avoid memory leak.