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
1.0 KiB44 linesraw
1using Whisper.Internal;
2
3namespace Whisper
4{
5	/// <summary>Implement this abstract class to receive callbacks from the native code</summary>
6	public abstract class Callbacks
7	{
8		/// <summary>The callback is called before every encoder run.</summary>
9		/// <remarks>If it returns false, the processing is aborted.</remarks>
10		protected virtual bool onEncoderBegin( Context sender ) { return true; }
11
12		/// <summary>This callback is called on each new segment</summary>
13		protected virtual void onNewSegment( Context sender, int countNew ) { }
14
15		const int S_OK = 0;
16		const int S_FALSE = 1;
17		internal int encoderBegin( Context sender )
18		{
19			try
20			{
21				return onEncoderBegin( sender ) ? S_OK : S_FALSE;
22			}
23			catch( Exception ex )
24			{
25				NativeLogger.captureException( ex );
26				return ex.HResult;
27			}
28		}
29
30		internal int newSegment( Context sender, int countNew )
31		{
32			try
33			{
34				onNewSegment( sender, countNew );
35				return S_OK;
36			}
37			catch( Exception ex )
38			{
39				NativeLogger.captureException( ex );
40				return ex.HResult;
41			}
42		}
43	}
44}