mmorise / World

A high-quality speech analysis, manipulation and synthesis system
http://www.kisc.meiji.ac.jp/~mmorise/world/english
Other
1.19k stars 255 forks source link

How should CheapTrick be called ? #131

Closed SeleDreams closed 2 years ago

SeleDreams commented 2 years ago

Hi, I've been trying to use world but being pretty new to it i'm right now having some issues calling cheaptrick as my call results in a crash

here is my current code

int FreeResampler::Synthesizer::DioPhase(int sampleRate, int frameCount) {
    DioOption dioOption;
    InitializeDioOption(&dioOption);
    dioOption.frame_period = Synthesizer::FRAME_PERIOD;
    f0Length = GetSamplesForDIO(sampleRate,frameCount,Synthesizer::FRAME_PERIOD);
    f0.reset(new double[f0Length]);
    timePositions.reset(new double[f0Length]);

    // Start analysis
    Dio(audioFile->getSample().get(), frameCount, sampleRate, &dioOption, timePositions.get(), f0.get());
    for (int i = 0;i < f0Length;i++)
    {
        std::cout << f0[i] << std::endl;
    }
    return EXIT_SUCCESS;
}

int FreeResampler::Synthesizer::CheapTrickPhase(int sampleRate, int frameCount) {
    CheapTrickOption cheapTrickOption;
    InitializeCheapTrickOption(sampleRate,&cheapTrickOption);
    double *tempSpectogram = new double[f0Length];
    CheapTrick(audioFile->getSample().get(), frameCount, sampleRate, timePositions.get(), f0.get(),f0Length,&cheapTrickOption,&tempSpectogram);
    spectogram.reset(tempSpectogram);
    return EXIT_SUCCESS;
}

when I run it though, cheaptrick crashes at line 222 when ' spectrogram[i][j] = spectral_envelope[j];' is called

SeleDreams commented 2 years ago

I was able to avoid a crash by doing this

int FreeResampler::Synthesizer::CheapTrickPhase(int sampleRate, int frameCount) {
    CheapTrickOption cheapTrickOption;
    InitializeCheapTrickOption(sampleRate,&cheapTrickOption);
    auto **tempSpectogram = new double *[f0Length]                                                                                        ];
    for (int i = 0; i < f0Length; i++)
    {
        tempSpectogram[i] = new double[frameCount ];
    }
    CheapTrick(audioFile->getSample().get(), frameCount, sampleRate, timePositions.get(), f0.get(),f0Length,&cheapTrickOption,tempSpectogram);
    spectogram.reset(tempSpectogram);
    return EXIT_SUCCESS;
}

but i'm not sure this is correct