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