yum-archive/TaSTT-Whisper

High-performance GPGPU inference of OpenAI's Whisper automatic speech recognition (ASR) model

git clone https://git.yummers.dev/yum-archive/TaSTT-Whisper

KonstantinSource codes8c4603c

master
2.3 KiB95 linesraw
1// Missing XML comment for publicly visible type or member
2// TODO: remove this line and document them.
3#pragma warning disable CS1591
4
5namespace Whisper
6{
7	/// <summary>Available sampling strategies</summary>
8	public enum eSamplingStrategy: int
9	{
10		/// <summary>Always select the most probable token</summary>
11		Greedy,
12		/// <summary>TODO: not implemented yet!</summary>
13		BeamSearch,
14	};
15
16	[Flags]
17	public enum eFullParamsFlags: uint
18	{
19		None = 0,
20		Translate = 1,
21		NoContext = 2,
22		SingleSegment = 4,
23		PrintSpecial = 8,
24		PrintProgress = 0x10,
25		PrintRealtime = 0x20,
26		PrintTimestamps = 0x40,
27
28		// Experimental
29		TokenTimestamps = 0x100,
30		SpeedupAudio = 0x200,
31	};
32
33	/// <summary>Transcribe parameters</summary>
34	public struct Parameters
35	{
36		/// <summary>Sampling strategy</summary>
37		public eSamplingStrategy strategy;
38
39		/// <summary>Count of CPU worker threads to use</summary>
40		/// <remarks>So far, the GPU model only uses CPU threads for MEL spectrograms</remarks>
41		public int cpuThreads;
42
43		public int n_max_text_ctx;
44		/// <summary>start offset in ms</summary>
45		public int offset_ms;
46		/// <summary>audio duration to process in ms</summary>
47		public int duration_ms;
48		public eFullParamsFlags flags;
49
50		/// <summary>Set or clear the specified flag in the <see cref="flags" /> field of this structure</summary>
51		public void setFlag( eFullParamsFlags flag, bool set )
52		{
53			if( flag != eFullParamsFlags.None )
54			{
55				if( set )
56					flags |= flag;
57				else
58					flags &= ~flag;
59				return;
60			}
61			throw new ArgumentException();
62		}
63
64		/// <summary>Language</summary>
65		public eLanguage language;
66
67		// [EXPERIMENTAL] token-level timestamps
68		/// <summary>timestamp token probability threshold (~0.01)</summary>
69		public float thold_pt;
70		/// <summary>timestamp token sum probability threshold (~0.01)</summary>
71		public float thold_ptsum;
72		/// <summary>max segment length in characters</summary>
73		public int max_len;
74		/// <summary>max tokens per segment (0 = no limit)</summary>
75		public int max_tokens;
76
77		public struct sGreedy
78		{
79			public int n_past;
80		}
81		public sGreedy greedy;
82
83		public struct sBeamSearch
84		{
85			public int n_past;
86			public int beam_width;
87			public int n_best;
88		}
89		public sBeamSearch beamSearch;
90
91		// [EXPERIMENTAL] speed-up techniques
92		/// <summary>overwrite the audio context size (0 = use default)</summary>
93		public int audioContextSize;
94	}
95}