Skip to content

Commit

Permalink
Merge pull request #31 from GewoonJaap/feature/winwhsiper-update
Browse files Browse the repository at this point in the history
WinWhisper update
  • Loading branch information
GewoonJaap authored Oct 12, 2024
2 parents c86c02e + b0272c4 commit d958a50
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<AssemblyName>WinWhisper</AssemblyName>
<ApplicationIcon>WinWhisper-White_Icon.ico</ApplicationIcon>
<Platforms>AnyCPU;ARM64</Platforms>
<Version>1.4.0</Version>
<Version>1.4.1</Version>
<Description>WinWhisper is a Windows application that uses AI to detect and remove background noise from audio files.</Description>
<Authors>Jaap</Authors>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
Expand All @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Include="Clowd.Squirrel" Version="2.11.1" />
<PackageReference Include="Sentry" Version="4.12.0" />
<PackageReference Include="Sentry" Version="4.12.1" />
</ItemGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ private static GatherVideoResult GatherVideosToConvert()
//if path starts and ends with ", remove
inputPath = PathUtil.FormatPath(inputPath);
var modelType = ConsoleUtil.AskForModelType();
Console.WriteLine($"Selected model: {modelType}");
var videos = VideoFinder.FindVideosBasedOnPath(inputPath);

return new GatherVideoResult(videos, subtitleOutputPath, modelType);
Expand Down
3 changes: 2 additions & 1 deletion Data/Enum/WinWhisperModelType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public enum WinWhisperModelType
Small,
SmallEn,
Tiny,
TinyEn
TinyEn,
LargeV3Turbo
}
}
8 changes: 5 additions & 3 deletions Utility/ConsoleUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Utility;

public static class ConsoleUtil
{
private const string DEFAULT_MODEL_TYPE = "base";
private const string DEFAULT_MODEL_TYPE = "large-v3-turbo";
public static string AskForLanguageCode(string fileName)
{
Console.WriteLine($"In which language code (en,nl etc) is the audio for video: {fileName}? Leave empty to auto detect");
Expand All @@ -19,7 +19,9 @@ public static string AskForLanguageCode(string fileName)

public static WinWhisperModelType AskForModelType()
{
Console.WriteLine("Which model type do you want to use? (base, base-en, large-v2, large-v1, large-v3, medium, medium-en, small, small-en, tiny, tiny-en)");
var modelTypes = ModelNameFetcher.GetModelTypes();
var modelTypesText = string.Join(", ", modelTypes);
Console.WriteLine($"Which model type do you want to use? ({modelTypesText})");
Console.WriteLine($"Default: {DEFAULT_MODEL_TYPE}");
var modelType = Console.ReadLine() ?? DEFAULT_MODEL_TYPE;
if(modelType.Trim().Length == 0)
Expand All @@ -28,7 +30,7 @@ public static WinWhisperModelType AskForModelType()
}
try
{
return ModelNameFetcher.StringToModelType(modelType.ToLower());
return ModelNameFetcher.StringToModelType(modelType);
}
catch
{
Expand Down
14 changes: 13 additions & 1 deletion Utility/ModelNameFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static string GgmlTypeToString(GgmlType modelType)
GgmlType.SmallEn => "small-en",
GgmlType.Tiny => "tiny",
GgmlType.TinyEn => "tiny-en",
GgmlType.LargeV3Turbo => "large-v3-turbo",
_ => throw new WinWhisperModelNotFoundException(modelType.ToString())
};

Expand All @@ -29,7 +30,11 @@ public static string GgmlTypeToString(GgmlType modelType)

public static WinWhisperModelType StringToModelType(string modelType)
{
return modelType switch
if (Enum.TryParse<WinWhisperModelType>(modelType, true, out var result))
{
return result;
}
return modelType.ToLower() switch
{
"base" => WinWhisperModelType.Base,
"base-en" => WinWhisperModelType.BaseEn,
Expand All @@ -42,6 +47,7 @@ public static WinWhisperModelType StringToModelType(string modelType)
"small-en" => WinWhisperModelType.SmallEn,
"tiny" => WinWhisperModelType.Tiny,
"tiny-en" => WinWhisperModelType.TinyEn,
"large-v3-turbo" => WinWhisperModelType.LargeV3Turbo,
_ => throw new WinWhisperModelNotFoundException(modelType)
};
}
Expand All @@ -61,7 +67,13 @@ public static GgmlType ModelTypeToGgmlType(WinWhisperModelType modelType)
WinWhisperModelType.SmallEn => GgmlType.SmallEn,
WinWhisperModelType.Tiny => GgmlType.Tiny,
WinWhisperModelType.TinyEn => GgmlType.TinyEn,
WinWhisperModelType.LargeV3Turbo => GgmlType.LargeV3Turbo,
_ => throw new WinWhisperModelNotFoundException(modelType.ToString())
};
}

public static List<string> GetModelTypes()
{
return Enum.GetValues(typeof(WinWhisperModelType)).Cast<WinWhisperModelType>().Select(x => x.ToString()).ToList();
}
}
4 changes: 2 additions & 2 deletions Utility/Utility.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Whisper.net" Version="1.5.0" />
<PackageReference Include="Whisper.net.Runtime" Version="1.5.0" />
<PackageReference Include="Whisper.net" Version="1.7.0" />
<PackageReference Include="Whisper.net.Runtime" Version="1.7.0" />
<PackageReference Include="MimeTypeMapOfficial" Version="1.0.17" />
</ItemGroup>

Expand Down
4 changes: 2 additions & 2 deletions WhisperAI/WhisperAI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Whisper.net" Version="1.5.0" />
<PackageReference Include="Whisper.net.Runtime" Version="1.5.0" />
<PackageReference Include="Whisper.net" Version="1.7.0" />
<PackageReference Include="Whisper.net.Runtime" Version="1.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d958a50

Please sign in to comment.