mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-21 18:52:36 +01:00
Include cpu info tool
This commit is contained in:
parent
6e540a18d1
commit
fecea629c1
@ -20,6 +20,7 @@
|
||||
* Add more settings for "Delete auto-backup after" - thx pahtashow
|
||||
* Add more options for actor in custom text export - thx Francois
|
||||
* Improve video auto load (allow eg. "_nl") - thx Hilde
|
||||
* Improve fix italic tags - thx uckthis
|
||||
* FIXED:
|
||||
* Fix VLC video player not working
|
||||
* Fix for ASSA timestamps (rounding output) - thx Jerome
|
||||
|
@ -207,6 +207,13 @@ COPY /Y /V "Newtonsoft.Json.dll" "temp_zip\"
|
||||
COPY /Y /V "System.Net.Http.Primitives.dll" "temp_zip\"
|
||||
COPY /Y /V "NAudio.Core.dll" "temp_zip\"
|
||||
COPY /Y /V "NAudio.WinMM.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Hardware.Common.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Hardware.CrossPlatform.Cpuid.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Interop.CrossPlatform.Cpuid.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Interop.Shared.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Hardware.Specification.Cpuid.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Logging.dll" "temp_zip\"
|
||||
COPY /Y /V "Microsoft.Win32.Registry.dll" "temp_zip\"
|
||||
COPY /Y /V "SubtitleEdit.exe" "temp_zip\"
|
||||
COPY /Y /V "Languages\*.xml" "temp_zip\Languages\"
|
||||
|
@ -181,6 +181,13 @@ COPY /Y /V "Newtonsoft.Json.dll" "temp_zip\"
|
||||
COPY /Y /V "System.Net.Http.Primitives.dll" "temp_zip\"
|
||||
COPY /Y /V "NAudio.Core.dll" "temp_zip\"
|
||||
COPY /Y /V "NAudio.WinMM.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Hardware.Common.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Hardware.CrossPlatform.Cpuid.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Interop.CrossPlatform.Cpuid.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Core.Interop.Shared.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Hardware.Specification.Cpuid.dll" "temp_zip\"
|
||||
COPY /Y /V "iTin.Logging.dll" "temp_zip\"
|
||||
COPY /Y /V "Microsoft.Win32.Registry.dll" "temp_zip\"
|
||||
COPY /Y /V "SubtitleEdit.exe" "temp_zip\"
|
||||
COPY /Y /V "Languages\*.xml" "temp_zip\Languages\"
|
||||
|
@ -314,6 +314,12 @@ Source: {#bindir}\System.Net.Http.Extensions.dll; DestDir: {app};
|
||||
Source: {#bindir}\System.Net.Http.Primitives.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\NAudio.Core.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\NAudio.WinMM.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\iTin.Core.Hardware.Common.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\iTin.Core.Hardware.CrossPlatform.Cpuid.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\iTin.Core.Interop.CrossPlatform.Cpuid.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\iTin.Core.Interop.Shared.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\iTin.Hardware.Specification.Cpuid.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\iTin.Logging.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: {#bindir}\Microsoft.Win32.Registry.dll; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: ..\Changelog.txt; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
Source: ..\LICENSE.txt; DestDir: {app}; Flags: ignoreversion; Components: main
|
||||
@ -356,6 +362,13 @@ Type: files; Name: {app}\System.Net.Http.Extensions.dll; Check: IsU
|
||||
Type: files; Name: {app}\System.Net.Http.Primitives.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\NAudio.Core.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\NAudio.WinMM.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Core.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Core.Hardware.Common.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Core.Hardware.CrossPlatform.Cpuid.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Core.Interop.CrossPlatform.Cpuid.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Core.Interop.Shared.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Hardware.Specification.Cpuid.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\iTin.Logging.dll; Check: IsUpgrade()
|
||||
Type: files; Name: {app}\Microsoft.Win32.Registry.dll; Check: IsUpgrade()
|
||||
|
||||
|
||||
|
@ -442,6 +442,24 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
}
|
||||
|
||||
resultTexts = results;
|
||||
|
||||
try
|
||||
{
|
||||
if (!File.Exists(srtFileName))
|
||||
{
|
||||
File.Delete(srtFileName);
|
||||
}
|
||||
|
||||
if (!File.Exists(vttFileName))
|
||||
{
|
||||
File.Delete(vttFileName);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
22
src/ui/Forms/AudioToText/WhisperDownload.Designer.cs
generated
22
src/ui/Forms/AudioToText/WhisperDownload.Designer.cs
generated
@ -30,6 +30,7 @@
|
||||
{
|
||||
this.labelDescription1 = new System.Windows.Forms.Label();
|
||||
this.labelPleaseWait = new System.Windows.Forms.Label();
|
||||
this.labelAVX2 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelDescription1
|
||||
@ -37,9 +38,9 @@
|
||||
this.labelDescription1.AutoSize = true;
|
||||
this.labelDescription1.Location = new System.Drawing.Point(21, 27);
|
||||
this.labelDescription1.Name = "labelDescription1";
|
||||
this.labelDescription1.Size = new System.Drawing.Size(145, 13);
|
||||
this.labelDescription1.Size = new System.Drawing.Size(132, 13);
|
||||
this.labelDescription1.TabIndex = 29;
|
||||
this.labelDescription1.Text = "Downloading Tesseract OCR";
|
||||
this.labelDescription1.Text = "Downloading Whisper.cpp";
|
||||
//
|
||||
// labelPleaseWait
|
||||
//
|
||||
@ -50,17 +51,29 @@
|
||||
this.labelPleaseWait.TabIndex = 28;
|
||||
this.labelPleaseWait.Text = "Please wait...";
|
||||
//
|
||||
// DownloadTesseract5
|
||||
// labelAVX2
|
||||
//
|
||||
this.labelAVX2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.labelAVX2.AutoSize = true;
|
||||
this.labelAVX2.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
|
||||
this.labelAVX2.Location = new System.Drawing.Point(274, 9);
|
||||
this.labelAVX2.Name = "labelAVX2";
|
||||
this.labelAVX2.Size = new System.Drawing.Size(34, 13);
|
||||
this.labelAVX2.TabIndex = 30;
|
||||
this.labelAVX2.Text = "AVX2";
|
||||
//
|
||||
// WhisperDownload
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(320, 93);
|
||||
this.Controls.Add(this.labelAVX2);
|
||||
this.Controls.Add(this.labelDescription1);
|
||||
this.Controls.Add(this.labelPleaseWait);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DownloadTesseract5";
|
||||
this.Name = "WhisperDownload";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Download Tesseract";
|
||||
@ -74,5 +87,6 @@
|
||||
|
||||
private System.Windows.Forms.Label labelDescription1;
|
||||
private System.Windows.Forms.Label labelPleaseWait;
|
||||
private System.Windows.Forms.Label labelAVX2;
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using Nikse.SubtitleEdit.Logic;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@ -9,8 +10,14 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
{
|
||||
public sealed partial class WhisperDownload : Form
|
||||
{
|
||||
public const string DownloadUrl = "https://github.com/SubtitleEdit/support-files/raw/master/whisper/whisper.cpp-2022-11-14.zip";
|
||||
private const string DownloadUrlAvx2 = "https://github.com/SubtitleEdit/support-files/raw/master/whisper/whisper.cpp-AVX2-2022-11-16.zip";
|
||||
private const string DownloadUrlSse2 = "https://github.com/SubtitleEdit/support-files/raw/master/whisper/whisper.cpp-SSE2-2022-11-16.zip";
|
||||
private readonly CancellationTokenSource _cancellationTokenSource;
|
||||
private static readonly string[] Sha512Hashes =
|
||||
{
|
||||
"ebbcb81782f5be763203d4e9b7a55b23d04997b0d0689c1af9638b0b5701db763569cb29d39593db84245e499876f930f64f4e758914fbfe39ad87a61cda8581", // AVX2
|
||||
"83d216fa1c1874be141c41b5bbdb61df9c447b5182787d8ae3d73c3cb6cf21743b0c7bfa6c45076938ed9629134882898623ab4932c8fde2fdee4fd5718e4bf3", // SSE2
|
||||
};
|
||||
|
||||
public WhisperDownload()
|
||||
{
|
||||
@ -25,12 +32,15 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
|
||||
private void WhisperDownload_Shown(object sender, EventArgs e)
|
||||
{
|
||||
var avx2 = CpuInfo.HasAvx2();
|
||||
labelAVX2.Visible = avx2;
|
||||
var downloadUrl = avx2 ? DownloadUrlAvx2 : DownloadUrlSse2;
|
||||
try
|
||||
{
|
||||
var httpClient = HttpClientHelper.MakeHttpClient();
|
||||
using (var downloadStream = new MemoryStream())
|
||||
{
|
||||
var downloadTask = httpClient.DownloadAsync(DownloadUrl, downloadStream, new Progress<float>((progress) =>
|
||||
var downloadTask = httpClient.DownloadAsync(downloadUrl, downloadStream, new Progress<float>((progress) =>
|
||||
{
|
||||
var pct = (int)Math.Round(progress * 100.0, MidpointRounding.AwayFromZero);
|
||||
labelPleaseWait.Text = LanguageSettings.Current.General.PleaseWait + " " + pct + "%";
|
||||
@ -55,19 +65,27 @@ namespace Nikse.SubtitleEdit.Forms.AudioToText
|
||||
{
|
||||
labelPleaseWait.Text = string.Empty;
|
||||
Cursor = Cursors.Default;
|
||||
MessageBox.Show($"Unable to download {DownloadUrl}!" + Environment.NewLine + Environment.NewLine +
|
||||
MessageBox.Show($"Unable to download {downloadUrl}!" + Environment.NewLine + Environment.NewLine +
|
||||
exception.Message + Environment.NewLine + Environment.NewLine + exception.StackTrace);
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
|
||||
private void CompleteDownload(Stream downloadStream)
|
||||
private void CompleteDownload(MemoryStream downloadStream)
|
||||
{
|
||||
if (downloadStream.Length == 0)
|
||||
{
|
||||
throw new Exception("No content downloaded - missing file or no internet connection!");
|
||||
}
|
||||
|
||||
downloadStream.Position = 0;
|
||||
var hash = Utilities.GetSha512Hash(downloadStream.ToArray());
|
||||
if (!Sha512Hashes.Contains(hash))
|
||||
{
|
||||
MessageBox.Show("Whisper SHA-512 hash does not match!");
|
||||
return;
|
||||
}
|
||||
|
||||
var folder = Path.Combine(Configuration.DataDirectory, "Whisper");
|
||||
if (!Directory.Exists(folder))
|
||||
{
|
||||
|
21
src/ui/Logic/CpuInfo.cs
Normal file
21
src/ui/Logic/CpuInfo.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using iTin.Hardware.Specification.Cpuid;
|
||||
using iTin.Hardware.Specification;
|
||||
|
||||
namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
public static class CpuInfo
|
||||
{
|
||||
public static bool HasAvx2()
|
||||
{
|
||||
try
|
||||
{
|
||||
var avx2 = CPUID.Instance.Leafs.GetProperty(LeafProperty.ExtendedFeatures.AVX2);
|
||||
return avx2.Success && (bool)avx2.Result.Value;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,27 @@
|
||||
<HintPath>DLLs\Interop.QuartzTypeLib.dll</HintPath>
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Core, Version=2.0.0.4, Culture=neutral, PublicKeyToken=91c459d24f0559c7, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Core.Hardware.Common, Version=1.0.0.4, Culture=neutral, PublicKeyToken=55a914aaf3e07893, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Core.Hardware.Common.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Core.Hardware.CrossPlatform.Cpuid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=55a914aaf3e07893, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Core.Hardware.CrossPlatform.Cpuid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Core.Interop.CrossPlatform.Cpuid, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1863a70dcfb63184, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Core.Interop.CrossPlatform.Cpuid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Core.Interop.Shared, Version=1.0.0.3, Culture=neutral, PublicKeyToken=1863a70dcfb63184, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Core.Interop.Shared.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Hardware.Specification.Cpuid, Version=1.0.0.2, Culture=neutral, PublicKeyToken=4854c22d6845e07c, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Hardware.Specification.Cpuid.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="iTin.Logging, Version=1.0.0.1, Culture=neutral, PublicKeyToken=1f353418c19ff38d, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\iCPUID.1.0.5\lib\net461\iTin.Logging.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Win32.Registry, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\Microsoft.Win32.Registry.5.0.0\lib\net461\Microsoft.Win32.Registry.dll</HintPath>
|
||||
</Reference>
|
||||
@ -1367,6 +1388,7 @@
|
||||
<Compile Include="Logic\CommandLineConvert\TsConvert.cs" />
|
||||
<Compile Include="Logic\CommandLineConvert\TsToBluRaySup.cs" />
|
||||
<Compile Include="Logic\CpsLineLength.cs" />
|
||||
<Compile Include="Logic\CpuInfo.cs" />
|
||||
<Compile Include="Logic\CurrentLanguage.cs" />
|
||||
<Compile Include="Logic\DarkTheme.cs" />
|
||||
<Compile Include="Logic\FileTypeAssociations.cs" />
|
||||
@ -2407,6 +2429,8 @@
|
||||
</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.38\build\Vosk.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Vosk.0.3.38\build\Vosk.targets'))" />
|
||||
<Error Condition="!Exists('..\..\packages\iCPUID.1.0.5\build\net461\iCPUID.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\iCPUID.1.0.5\build\net461\iCPUID.targets'))" />
|
||||
</Target>
|
||||
<Import Project="..\..\packages\Vosk.0.3.38\build\Vosk.targets" Condition="Exists('..\..\packages\Vosk.0.3.38\build\Vosk.targets')" />
|
||||
<Import Project="..\..\packages\iCPUID.1.0.5\build\net461\iCPUID.targets" Condition="Exists('..\..\packages\iCPUID.1.0.5\build\net461\iCPUID.targets')" />
|
||||
</Project>
|
@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="iCPUID" version="1.0.5" targetFramework="net48" />
|
||||
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net462" />
|
||||
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net462" />
|
||||
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net462" />
|
||||
|
Loading…
Reference in New Issue
Block a user