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.4 KiB64 linesraw
1#pragma once
2#include <whisperWindows.h>
3#include <deque>
4#include <unordered_set>
5
6class AppState;
7class DebugConsole
8{
9	using eLogLevel = Whisper::eLogLevel;
10
11	struct Entry
12	{
13		eLogLevel level;
14		CStringA message;
15		HRESULT print( HANDLE hConsole, CString& tempString ) const;
16	};
17
18	CComAutoCriticalSection critSec;
19	std::deque<Entry> buffer;
20	CString tempString;
21	CHandle output;
22
23	inline void logSink( eLogLevel lvl, const char* message );
24	static void __stdcall logSinkStatic( void* context, eLogLevel lvl, const char* message );
25
26	static BOOL __stdcall consoleHandlerRoutine( DWORD dwCtrlType );
27
28	static DebugConsole* pGlobalInstance;
29	void windowClosed();
30
31	std::unordered_set<CButton*> checkboxes;
32
33	CStringA tempStringA;
34	void log( eLogLevel lvl, const char* pszFormat, va_list args );
35
36public:
37	HRESULT initialize( eLogLevel level = eLogLevel::Debug );
38	~DebugConsole();
39
40	HRESULT show();
41	HRESULT hide();
42	bool isVisible() const { return output; }
43
44	void addCheckbox( CButton& cb );
45	void removeCheckbox( CButton& cb );
46
47	static void logMessage( eLogLevel lvl, const char* pszFormat, va_list args );
48};
49
50class ConsoleCheckbox
51{
52	CButton control;
53	DebugConsole* console = nullptr;
54
55public:
56	HRESULT initialize( HWND dialog, int idc, AppState& state );
57	void click();
58	~ConsoleCheckbox()
59	{
60		if( nullptr != console )
61			console->removeCheckbox( control );
62	}
63	void ensureChecked();
64};