mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 11:12:36 +01:00
Add read for Audacity label format - thx David :)
This commit is contained in:
parent
38fa31398f
commit
e135a7c77a
40
src/libse/SubtitleFormats/AudacityLabels.cs
Normal file
40
src/libse/SubtitleFormats/AudacityLabels.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
@ -651,6 +651,7 @@ namespace Nikse.SubtitleEdit.Core.SubtitleFormats
|
||||
new MacCaption10(),
|
||||
new Rdf1(),
|
||||
new CombinedXml(),
|
||||
new AudacityLabels(),
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user