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
e1e3ac0
master
1#pragma once 2#include "../../ComLightLib/comLightCommon.h" 3#include "iTranscribeResult.cl.h" 4#include "SpecialTokens.h" 5#include "loggerApi.h" 6#include "sLanguageList.h" 7#include "sLoadModelCallbacks.h" 8#include "eGpuModelFlags.h" 9 10namespace Whisper 11{ 12struct iModel ; 13struct iAudioBuffer ; 14struct iAudioReader ; 15struct iAudioCapture ; 16struct sCaptureCallbacks ; 17struct sFullParams ; 18enum struct eModelImplementation :uint32_t ; 19enum struct eSamplingStrategy :int ; 20using whisper_token = int ; 21struct sProgressSink ; 22 23struct DECLSPEC_NOVTABLE iContext :public ComLight ::IUnknown 24 { 25DEFINE_INTERFACE_ID ("{b9956374-3b18-4943-90f2-2ab18a404537}" ); 26 27// Run the entire model: PCM -> log mel spectrogram -> encoder -> decoder -> text 28// Uses the specified decoding strategy to obtain the text. 29virtual HRESULT COMLIGHTCALL runFull (const sFullParams & params ,const iAudioBuffer * buffer )= 0 ; 30virtual HRESULT COMLIGHTCALL runStreamed (const sFullParams & params ,const sProgressSink & progress ,const iAudioReader * reader )= 0 ; 31virtual HRESULT COMLIGHTCALL runCapture (const sFullParams & params ,const sCaptureCallbacks & callbacks ,const iAudioCapture * reader )= 0 ; 32 33virtual HRESULT COMLIGHTCALL getResults (eResultFlags flags ,iTranscribeResult ** pp )const = 0 ; 34// Try to detect speaker by comparing channels of the stereo PCM data 35virtual HRESULT COMLIGHTCALL detectSpeaker (const sTimeInterval & time ,eSpeakerChannel & result )const = 0 ; 36 37virtual HRESULT COMLIGHTCALL getModel (iModel ** pp )= 0 ; 38 39virtual HRESULT COMLIGHTCALL fullDefaultParams (eSamplingStrategy strategy ,sFullParams * rdi )= 0 ; 40 41// Performance information 42virtual HRESULT COMLIGHTCALL timingsPrint ()= 0 ; 43virtual HRESULT COMLIGHTCALL timingsReset ()= 0 ; 44 }; 45 46struct DECLSPEC_NOVTABLE iModel :public ComLight ::IUnknown 47 { 48DEFINE_INTERFACE_ID ("{abefb4c9-e8d8-46a3-8747-5afbadef1adb}" ); 49 50virtual HRESULT COMLIGHTCALL createContext (iContext ** pp )= 0 ; 51 52virtual HRESULT COMLIGHTCALL isMultilingual ()= 0 ; 53 54virtual HRESULT COMLIGHTCALL getSpecialTokens (SpecialTokens & rdi )= 0 ; 55 56// Token Id -> String 57virtual const char * COMLIGHTCALL stringFromToken (whisper_token token )= 0 ; 58 }; 59 60HRESULT COMLIGHTCALL setupLogger (const sLoggerSetup & setup ); 61HRESULT COMLIGHTCALL loadModel (const wchar_t * path ,eModelImplementation impl ,uint32_t flags ,const sLoadModelCallbacks * callbacks ,iModel ** pp ); 62 63uint32_t COMLIGHTCALL findLanguageKeyW (const wchar_t * lang ); 64uint32_t COMLIGHTCALL findLanguageKeyA (const char * lang ); 65 66HRESULT COMLIGHTCALL getSupportedLanguages (sLanguageList & rdi ); 67} 68 69#include "sFullParams.h"