mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Fix for divide by zero in tts
This commit is contained in:
parent
0b90c931a6
commit
ddeee56e03
@ -454,7 +454,7 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
progressBar1.Value = 0;
|
progressBar1.Value = 0;
|
||||||
progressBar1.Maximum = subtitle.Paragraphs.Count;
|
progressBar1.Maximum = subtitle.Paragraphs.Count;
|
||||||
progressBar1.Visible = true;
|
progressBar1.Visible = true;
|
||||||
var ext = ".wav";
|
const string ext = ".wav";
|
||||||
|
|
||||||
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
|
for (var index = 0; index < subtitle.Paragraphs.Count; index++)
|
||||||
{
|
{
|
||||||
@ -524,7 +524,15 @@ namespace Nikse.SubtitleEdit.Forms.Tts
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var factor = (decimal)waveInfo.TotalMilliseconds / (decimal)(p.DurationTotalMilliseconds + addDuration);
|
var divisor = (decimal)(p.DurationTotalMilliseconds + addDuration);
|
||||||
|
if (divisor <= 0)
|
||||||
|
{
|
||||||
|
SeLogger.Error($"TextToSpeech: Duration is zero (skipping): {pFileName}, {p}");
|
||||||
|
fileNames.Add(new FileNameAndSpeedFactor { Filename = pFileName, Factor = 1 });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var factor = (decimal)waveInfo.TotalMilliseconds / divisor;
|
||||||
var outputFileName2 = Path.Combine(_waveFolder, $"{index}_{Guid.NewGuid()}{ext}");
|
var outputFileName2 = Path.Combine(_waveFolder, $"{index}_{Guid.NewGuid()}{ext}");
|
||||||
if (!string.IsNullOrEmpty(overrideFileName) && File.Exists(Path.Combine(_waveFolder, overrideFileName)))
|
if (!string.IsNullOrEmpty(overrideFileName) && File.Exists(Path.Combine(_waveFolder, overrideFileName)))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user