Add read for Audacity label format - thx David :)

This commit is contained in:
niksedk 2021-11-08 22:06:04 +01:00
parent 38fa31398f
commit e135a7c77a
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,40 @@
using Nikse.SubtitleEdit.Core.Common;
using System;
using System.Collections.Generic;
using System.Globalization;
namespace Nikse.SubtitleEdit.Core.SubtitleFormats
{
public class AudacityLabels : SubtitleFormat
{
public override string Extension => ".txt";
public override string Name => "Audacity labels";
public override void LoadSubtitle(Subtitle subtitle, List<string> lines, string fileName)
{
_errorCount = 0;
foreach (var line in lines)
{
var arr = line.Split('\t');
if (arr.Length == 3 &&
double.TryParse(arr[0], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var start) &&
double.TryParse(arr[1], NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out var end))
{
subtitle.Paragraphs.Add(new Paragraph(arr[2], start * TimeCode.BaseUnit, end * TimeCode.BaseUnit));
}
else
{
_errorCount++;
}
}
subtitle.Renumber();
}
public override string ToText(Subtitle subtitle, string title)
{
throw new NotImplementedException();
}
}
}

View File

@ -651,6 +651,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
new MacCaption10(), new MacCaption10(),
new Rdf1(), new Rdf1(),
new CombinedXml(), new CombinedXml(),
new AudacityLabels(),
}; };
} }