setReference method

void setReference(
  1. List<double> pcm,
  2. int sampleRate,
  3. int nChannels,
  4. String referenceFeature,
)

Sets the reference audio for voice cloning (GPT-SoVITS models).

pcm is the PCM audio data as a list of float values. sampleRate is the sample rate of the reference audio in Hz. nChannels is the number of audio channels. referenceFeature is the phoneme feature string of the reference text.

Implementation

void setReference(List<double> pcm, int sampleRate, int nChannels, String referenceFeature){
  if (!available) {
    throw Exception("Model not opened yet. wait one second and try again.");
  }

  ffi.Pointer<ffi.Float> waveBuf = malloc<ffi.Float>(pcm.length);
  for (int i = 0; i < pcm.length; i++) {
    waveBuf[i] = pcm[i];
  }

  int status = ailiaVoice.ailiaVoiceSetReference(
    ppAilia!.value,
    waveBuf,
    pcm.length * 4,
    nChannels,
    sampleRate,
    referenceFeature.toNativeUtf8().cast<ffi.Char>()
  );
  throwError("ailiaVoiceSetReference", status);

  malloc.free(waveBuf);
}