Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infinite loop in "Change gender" #1926

Closed
YannickJadoul opened this issue Nov 15, 2021 · 4 comments
Closed

Infinite loop in "Change gender" #1926

YannickJadoul opened this issue Nov 15, 2021 · 4 comments

Comments

@YannickJadoul
Copy link

I got an issue reported at YannickJadoul/Parselmouth#68 by @auspicious3000, that in some cases, "Change gender"'s execution blocks.

@auspicious3000 very kindly provided me an minimal reproducing example of a case in which this happens, and it seems that the error lies somewhere in Praat, as I can reproduce the issue in Praat.

The following should reproduce the error (tried out in Praat 6.1.51, and in the latest master version):

  • Read the FLAC file in this zip file into Praat: 2552-132097-0069.zip
    (Apologies for the zip file, but GitHub only allows to upload certain file types/extensions into an issue.)
  • Run "Change gender", with parameters: 50, 250, 0.79, 105.469, 1.487, 1.0
  • Praat hangs and gets into an infinite loop.

I've compiled a debug version of Praat and found out the following:

  • According to my debugger, the infinite loop happens at
    while (ttarget < endOfTargetVoice) {
    as endOfTargetNoise is +inf.
  • endOfTargetNoise is +inf, because of a division by zero at
    finishingPeriod = 1.0 / RealTier_getValueAtTime (pitch, endOfSourceVoice);

I haven't looked further than this, trying to figure out why RealTier_getValueAtTime (pitch, endOfSourceVoice) on line 399 results in 0. If I do figure out more, I will update!

@PaulBoersma
Copy link
Member

For this example, Praat 6.2.02 will bail out with an appropriate error message, which is "Change gender: your pitch manipulation would lead to negative pitch values." Thanks for the excellent bug hunt.

@YannickJadoul
Copy link
Author

Thank you for solving this!

One small additional question: in older versions of Praat (before the 6.2.02 fix), is there a way of detecting when this would happen, in order to not call "Change gender" on this audio with these parameters, and avoid getting stuck in this infinite loop?

@PaulBoersma
Copy link
Member

Instead of "Sound: Change gender", you could compute the pitch yourself (with the given minimum and maximum pitch) and do "Sound & Pitch: Change Gender". Once you have the Pitch, you can query its minimum (without interpolation) and median, and check whether the resulting pitch value will be less than 0:

scaledMinimum = minimum * newMedian / median
resultingMinimum = newMedian + (scaledMinimum - newMedian) * pitchRangefactor
if (resultingMinimum <= 0.0) ...

@YannickJadoul
Copy link
Author

Thank you very much! This will be quite useful to @auspicious3000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants