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

KonstantinUX improvement, populate output path9c30dd0

master
2.0 KiB77 linesraw
1#pragma once
2#include <iContext.h>
3#include "logger.h"
4
5CString formatErrorMessage( HRESULT hr );
6
7void reportFatalError( const char* what, HRESULT hr );
8
9#define CHECK( hr ) { const HRESULT __hr = ( hr ); if( FAILED( __hr ) ) return __hr; }
10
11HRESULT implParse( const CString& s, Whisper::eModelImplementation& rdi );
12
13LPCTSTR implString( Whisper::eModelImplementation i );
14
15void implPopulateCombobox( CComboBox& cb, Whisper::eModelImplementation impl );
16
17Whisper::eModelImplementation implGetValue( CComboBox& cb );
18
19__interface iThreadPoolCallback
20{
21	void __stdcall poolCallback() noexcept;
22};
23
24class ThreadPoolWork
25{
26	PTP_WORK work = nullptr;
27	static void __stdcall callback( PTP_CALLBACK_INSTANCE Instance, PVOID Context, PTP_WORK Work );
28
29public:
30
31	~ThreadPoolWork();
32	HRESULT create( iThreadPoolCallback* cb );
33	HRESULT post();
34};
35
36void makeUtf16( CString& rdi, const char* utf8 );
37void makeUtf8( CStringA& rdi, const CString& utf16 );
38
39bool getOpenFileName( HWND owner, LPCTSTR title, LPCTSTR filter, CString& path );
40
41bool getSaveFileName( HWND owner, LPCTSTR title, LPCTSTR filter, CString& path, DWORD* filterIndex = nullptr );
42
43#define ON_BUTTON_CLICK( id, func )  \
44	if( uMsg == WM_COMMAND &&        \
45         id == LOWORD( wParam ) )    \
46	{                                \
47		bHandled = TRUE;             \
48		func();                      \
49		lResult = 0;                 \
50		return TRUE;                 \
51	}
52
53void reportError( HWND owner, LPCTSTR text, LPCTSTR title, HRESULT hr = S_FALSE );
54
55inline const wchar_t* cstr( const CString& s ) { return s; }
56inline const char* cstr( const CStringA& s ) { return s; }
57
58inline HRESULT getLastHr()
59{
60	return HRESULT_FROM_WIN32( GetLastError() );
61}
62
63HRESULT writeUtf8Bom( CAtlFile& file );
64
65// Flip order of bytes from RGB to BGR, or vice versa
66inline uint32_t flipRgb( uint32_t val )
67{
68	val = _byteswap_ulong( val );
69	return val >> 8;
70}
71
72bool isInvalidTranslate( HWND owner, uint32_t lang, bool translate );
73
74inline bool isChecked( CButton& btn )
75{
76	return btn.GetCheck() == BST_CHECKED;
77}