textToSpeech method
General Library Documentation Undocument By General Corporation & Global Corporation & General Developer
Implementation
@override
FutureOr<String> textToSpeech({
required int numberThreads,
required String text,
required String ouputPath,
}) async {
if (_isInIsolate == false) {
final String modelPath = Outetts._modelPath;
final String modelVocoderPath = Outetts._modelVocoderPath;
return await Isolate.run(() async {
final Outetts outetts = Outetts();
outetts._isInIsolate = true;
await outetts.ensureInitialized();
await outetts.initialized();
outetts.loadModel(
modelPath: modelPath,
modelVocoderPath: modelVocoderPath,
);
return await outetts.textToSpeech(
numberThreads: numberThreads,
text: text,
ouputPath: ouputPath,
);
});
}
final options = calloc<outetts_options_t>();
options.ref.n_threads = numberThreads;
options.ref.text = text.toNativeUtf8().cast<Char>();
options.ref.output_path = ouputPath.toNativeUtf8().cast<Char>();
options.ref.model_path = Outetts._modelPath.toNativeUtf8().cast<Char>();
options.ref.model_vocoder_path =
Outetts._modelVocoderPath.toNativeUtf8().cast<Char>();
Outetts._outetts.outetts_inference(options.ref);
return ouputPath;
}