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
8c4603c
master
1#pragma once 2#include <vector> 3#include "comLightCommon.h" 4 5// COM interfaces to marshal streams across the interop. 6namespace ComLight 7{ 8enum struct eSeekOrigin :uint8_t 9 { 10Begin = 0 , 11Current = 1 , 12End = 2 13 }; 14 15namespace details 16 { 17template < class E > 18inline size_t sizeofVector (const std ::vector < E >& vec ) 19 { 20return sizeof (E )* vec .size (); 21 } 22 } 23 24// COM interface for readonly stream. You'll get these interfaces what you use [ReadStream] attribute in C#. 25struct DECLSPEC_NOVTABLE iReadStream :public IUnknown 26 { 27DEFINE_INTERFACE_ID ("006af6db-734e-4595-8c94-19304b2389ac" ); 28 29virtual HRESULT COMLIGHTCALL read (void * lpBuffer ,int nNumberOfBytesToRead ,int & lpNumberOfBytesRead )= 0 ; 30virtual HRESULT COMLIGHTCALL seek (int64_t offset ,eSeekOrigin origin )= 0 ; 31virtual HRESULT COMLIGHTCALL getPosition (int64_t & position )= 0 ; 32virtual HRESULT COMLIGHTCALL getLength (int64_t & length )= 0 ; 33 34template < class E > 35inline HRESULT read (std ::vector < E >& vec ) 36 { 37const int cb = (int )details ::sizeofVector (vec ); 38int cbRead = 0 ; 39CHECK (read (vec .data (),cb ,cbRead ) ); 40if (cbRead >=cb ) 41return S_OK ; 42return E_EOF ; 43 } 44 }; 45 46// COM interface for readonly stream. You'll get these interfaces what you use [WriteStream] attribute in C#. 47struct DECLSPEC_NOVTABLE iWriteStream :public IUnknown 48 { 49DEFINE_INTERFACE_ID ("d7c3eb39-9170-43b9-ba98-2ea1f2fed8a8" ); 50 51virtual HRESULT COMLIGHTCALL write (const void * lpBuffer ,int nNumberOfBytesToWrite )= 0 ; 52virtual HRESULT COMLIGHTCALL flush ()= 0 ; 53 54template < class E > 55inline HRESULT write (const std ::vector < E >& vec ) 56 { 57const int cb = (int )details ::sizeofVector (vec ); 58return write (vec .data (),cb ); 59 } 60 }; 61}