using ComLight; using System; using System.ComponentModel; using System.Runtime.InteropServices; namespace Whisper { /// Function pointer to receive array of tokens from [UnmanagedFunctionPointer( CallingConvention.StdCall )] public delegate void pfnDecodedTokens( [In, MarshalAs( UnmanagedType.LPArray, SizeParamIndex = 1 )] int[] arr, int length, IntPtr pv ); /// A model in VRAM, loaded from GGML file. /// This object doesn't keep any mutable state, and can be safely used from multiple threads concurrently [ComInterface( "abefb4c9-e8d8-46a3-8747-5afbadef1adb", eMarshalDirection.ToManaged ), CustomConventions( typeof( Internal.NativeLogger ) )] public interface iModel: IDisposable { /// Create a context to transcribe audio with this model /// Don't call this method, use instead. [RetValIndex, EditorBrowsable( EditorBrowsableState.Never )] Internal.iContext createContextInternal(); /// Convert the provided text into tokens [EditorBrowsable( EditorBrowsableState.Never )] void tokenize( [MarshalAs( UnmanagedType.LPUTF8Str )] string text, [MarshalAs( UnmanagedType.FunctionPtr )] pfnDecodedTokens pfn, IntPtr pv ); /// True if this model is multi-lingual bool isMultilingual(); /// Retrieve integer IDs of the special tokens defined by the model [RetValIndex] SpecialTokens getSpecialTokens(); /// Try to resolve integer token ID into string. /// Don't call this method, use instead. [EditorBrowsable( EditorBrowsableState.Never )] IntPtr stringFromTokenInternal( int id ); /// Clone the model /// You must pass bit when creating this model, otherwise this method will throw an exception. [RetValIndex] iModel clone(); } }