mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-22 03:02:35 +01:00
Update Vosk to 0.3.38
This commit is contained in:
parent
967ed180da
commit
8c0691d88c
@ -17,8 +17,10 @@
|
||||
* Update Portuguese translation - thx hugok79
|
||||
* Update French translation - thx Pierre
|
||||
* Update Korean translation - thx domddol
|
||||
* Update Italian translation - thx bovirus
|
||||
* Update dotnet framework to 4.8
|
||||
* Update Tesseract OCR to 5.1.0
|
||||
* Update Vosk to 0.3.38
|
||||
* Add some new English names - thx Omair
|
||||
* Add err msg if user OCR fix replacelist invalid - thx sialivi
|
||||
* Improve burn-in settings - thx Leon
|
||||
@ -29,7 +31,7 @@
|
||||
* Separate vertical margins in BD sup editor - thx von Suppé
|
||||
* Add new models for audio-to-text - thx Stefan
|
||||
* Improve ASSA support for "Remove Leading '...'" - thx von Suppé
|
||||
* Add 4 extra colors to recent colors in color picker
|
||||
* Add four extra colors to recent colors in color picker
|
||||
* Add a little vobsub support in spellcheck - thx cyzs233
|
||||
* Add error msg for audio-to-text with online video - thx ilCosmico
|
||||
* Try to keep assa tags after translate - thx eladkarako
|
||||
@ -38,9 +40,10 @@
|
||||
* Improve "gap info" in File - Statistics
|
||||
* Allow import time codes w empty subtitle - thx Heung
|
||||
* Improve audio to text post-processing for jp/cn - thx coastal45
|
||||
* Add Kurdish (Sorani) to GT - thx Ahmad
|
||||
* Add more GT languages - thx Ahmad/malik
|
||||
* Video track bar mouse wheel works as waveform - thx voblaunsane
|
||||
* Allow sort of issues in "Netflix quality check" - thx uckthis
|
||||
* Add four extra custom color shortcuts - thx Bill
|
||||
* FIXED:
|
||||
* Fix selected line update after load of new sub - thx Jamakmake
|
||||
* Removed vertical-scroll-bar-auto-show-hide as it could freeze SE
|
||||
|
@ -9,6 +9,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
@ -2980,5 +2981,24 @@ namespace Nikse.SubtitleEdit.Core.Common
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static string GetSha512Hash(byte[] buffer)
|
||||
{
|
||||
using (var ms = new MemoryStream(buffer))
|
||||
using (var bs = new BufferedStream(ms))
|
||||
{
|
||||
using (var sha512 = new SHA512Managed())
|
||||
{
|
||||
var hash = sha512.ComputeHash(bs);
|
||||
var hashString = string.Empty;
|
||||
foreach (var x in hash)
|
||||
{
|
||||
hashString += $"{x:x2}";
|
||||
}
|
||||
|
||||
return hashString.ToLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@ -12,6 +12,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
public bool AutoClose { get; internal set; }
|
||||
|
||||
public static readonly string[] VoskNewSha512Hashes =
|
||||
{
|
||||
"7baa07adeb613994cac43778627cda0df925ff12e3851d67ad1336e45ded51f2a07102d6df2685b296f533255bd5dcc6d36d635a26e8c1da935422f1d904205f", // 32-bit
|
||||
"e78db54a169f0b8ad859850f98621a54acb1902e2978043cea2787a618fd638ab690ef28694dd71b69f6aecad2292254c6cd073825268c3fcba23d8530668577", // 64-bit
|
||||
};
|
||||
|
||||
public DownloadVosk()
|
||||
{
|
||||
UiUtil.PreInitialize(this);
|
||||
@ -49,7 +55,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonOK.Enabled = false;
|
||||
Refresh();
|
||||
Cursor = Cursors.WaitCursor;
|
||||
var url = "https://github.com/SubtitleEdit/support-files/blob/master/vosk/vosk" + IntPtr.Size * 8 + ".tar.gz?raw=true";
|
||||
var url = "https://github.com/alphacep/vosk-api/releases/download/v0.3.38/vosk-win" + IntPtr.Size * 8 + "-0.3.38.zip?raw=true";
|
||||
var wc = new WebClient { Proxy = Utilities.GetProxy() };
|
||||
|
||||
wc.DownloadDataCompleted += wc_DownloadDataCompleted;
|
||||
@ -78,36 +84,33 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
var folder = Path.Combine(Configuration.DataDirectory, "Vosk");
|
||||
var tempFileName = FileUtil.GetTempFileName(".tar");
|
||||
using (var ms = new MemoryStream(e.Result))
|
||||
using (var fs = new FileStream(tempFileName, FileMode.Create))
|
||||
using (var zip = new GZipStream(ms, CompressionMode.Decompress))
|
||||
var hash = Utilities.GetSha512Hash(e.Result);
|
||||
if (!VoskNewSha512Hashes.Contains(hash))
|
||||
{
|
||||
byte[] buffer = new byte[1024];
|
||||
int nRead;
|
||||
while ((nRead = zip.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
fs.Write(buffer, 0, nRead);
|
||||
}
|
||||
MessageBox.Show("Vosk SHA-512 hash does not match!");
|
||||
return;
|
||||
}
|
||||
|
||||
using (var tr = new TarReader(tempFileName))
|
||||
var folder = Path.Combine(Configuration.DataDirectory, "Vosk");
|
||||
using (var ms = new MemoryStream(e.Result))
|
||||
using (var zip = ZipExtractor.Open(ms))
|
||||
{
|
||||
foreach (var th in tr.Files)
|
||||
var dir = zip.ReadCentralDir();
|
||||
foreach (var entry in dir)
|
||||
{
|
||||
string fn = Path.Combine(folder, th.FileName.Replace('/', Path.DirectorySeparatorChar));
|
||||
if (th.IsFolder)
|
||||
var name = entry.FilenameInZip;
|
||||
var idxOfSlash = name.IndexOf('/');
|
||||
if (idxOfSlash > 0)
|
||||
{
|
||||
Directory.CreateDirectory(Path.Combine(folder, th.FileName.Replace('/', Path.DirectorySeparatorChar)));
|
||||
}
|
||||
else if (th.FileSizeInBytes > 0)
|
||||
{
|
||||
th.WriteData(fn);
|
||||
name = name.Substring(idxOfSlash).TrimStart('/');
|
||||
if (name.Length > 0)
|
||||
{
|
||||
var path = Path.Combine(folder, name);
|
||||
zip.ExtractFile(entry, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File.Delete(tempFileName);
|
||||
|
||||
Cursor = Cursors.Default;
|
||||
labelPleaseWait.Text = string.Empty;
|
||||
|
@ -3,7 +3,6 @@ using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Forms
|
||||
@ -85,7 +84,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Directory.CreateDirectory(folder);
|
||||
}
|
||||
|
||||
var hash = GetSha512Hash(e.Result);
|
||||
var hash = Utilities.GetSha512Hash(e.Result);
|
||||
if (hash != Sha512Hash)
|
||||
{
|
||||
MessageBox.Show("yt-dlp SHA-512 hash does not match!");
|
||||
@ -106,24 +105,5 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonOK.Enabled = true;
|
||||
labelPleaseWait.Text = string.Format(LanguageSettings.Current.SettingsFfmpeg.XDownloadOk, "youtube-dl");
|
||||
}
|
||||
|
||||
private static string GetSha512Hash(byte[] buffer)
|
||||
{
|
||||
using (var ms = new MemoryStream(buffer))
|
||||
using (var bs = new BufferedStream(ms))
|
||||
{
|
||||
using (var sha512 = new SHA512Managed())
|
||||
{
|
||||
byte[] hash = sha512.ComputeHash(bs);
|
||||
string hashString = string.Empty;
|
||||
foreach (byte x in hash)
|
||||
{
|
||||
hashString += string.Format("{0:x2}", x);
|
||||
}
|
||||
|
||||
return hashString.ToString().ToLower();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33816,7 +33816,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
Directory.CreateDirectory(voskFolder);
|
||||
}
|
||||
|
||||
if (Configuration.IsRunningOnWindows && (!File.Exists(Path.Combine(voskFolder, "libvosk.dll"))))
|
||||
if (Configuration.IsRunningOnWindows && !HasCurrentVosk(voskFolder))
|
||||
{
|
||||
if (MessageBox.Show(string.Format(LanguageSettings.Current.Settings.DownloadX, "libvosk"), "Subtitle Edit", MessageBoxButtons.YesNoCancel) != DialogResult.Yes)
|
||||
{
|
||||
@ -33855,6 +33855,19 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasCurrentVosk(string voskFolder)
|
||||
{
|
||||
var voskDll = Path.Combine(voskFolder, "libvosk.dll");
|
||||
if (!File.Exists(voskDll))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var currentVoskDllSha512Hash = "0ed8187b9e109ebdc7c2022694224cacccc3b545b3ca0c204f3414cba4f0e758251fbab2bcbfeb565f3e166dbeab28712c30f6b9ccad3ea023abf7c5e8d2e92f";
|
||||
var hash = Utilities.GetSha512Hash(FileUtil.ReadAllBytesShared(voskDll));
|
||||
return currentVoskDllSha512Hash == hash;
|
||||
}
|
||||
|
||||
private void Main_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.X > 72 && e.X <= (122 + textBoxListViewText.Height))
|
||||
|
@ -86,7 +86,7 @@
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Vosk, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Vosk.0.3.32\lib\netstandard2.0\Vosk.dll</HintPath>
|
||||
<HintPath>..\..\packages\Vosk.0.3.38\lib\netstandard2.0\Vosk.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@ -2273,7 +2273,7 @@
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Vosk.0.3.32\build\Vosk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Vosk.0.3.32\build\Vosk.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\Vosk.0.3.38\build\Vosk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Vosk.0.3.38\build\Vosk.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\..\packages\Vosk.0.3.32\build\Vosk.targets" Condition="Exists('..\..\packages\Vosk.0.3.32\build\Vosk.targets')" />
|
||||
<Import Project="..\..\packages\Vosk.0.3.38\build\Vosk.targets" Condition="Exists('..\..\packages\Vosk.0.3.38\build\Vosk.targets')" />
|
||||
</Project>
|
@ -6,5 +6,5 @@
|
||||
<package id="ncalc" version="1.3.8" targetFramework="net472" />
|
||||
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net472" />
|
||||
<package id="NHunspell" version="1.2.5554.16953" targetFramework="net462" />
|
||||
<package id="Vosk" version="0.3.32" targetFramework="net472" />
|
||||
<package id="Vosk" version="0.3.38" targetFramework="net48" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user