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

KonstantinMinorc4cf795

master
1.3 KiB63 linesraw
1#include "stdafx.h"
2#include "AppState.h"
3#include "Utils/miscUtils.h"
4#include "LoadModelDlg.h"
5#include "TranscribeDlg.h"
6#include "CaptureDlg.h"
7
8static HRESULT dialogLoadModel( AppState& appState )
9{
10	LoadModelDlg loadDialog{ appState };
11	HRESULT hr = loadDialog.show();
12	if( FAILED( hr ) )
13	{
14		reportFatalError( "Error loading the model", hr );
15		return hr;
16	}
17	appState.automaticallyLoadModel = false;
18	return hr;
19}
20
21static HRESULT dialogTranscribe( AppState& appState )
22{
23	TranscribeDlg dialog{ appState };
24	return dialog.show();
25}
26
27static HRESULT dialogCapture( AppState& appState )
28{
29	CaptureDlg dialog{ appState };
30	return dialog.show();
31}
32
33using pfnDialog = HRESULT( * )( AppState& appState );
34static const std::array<pfnDialog, 4> s_dialogs =
35{
36	nullptr, // S_OK
37	&dialogLoadModel,   // SCREEN_MODEL
38	&dialogTranscribe,  // SCREEN_TRANSCRIBE
39	&dialogCapture,	    // SCREEN_CAPTURE
40};
41
42int __stdcall wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow )
43{
44	AppState appState;
45	HRESULT hr = appState.startup();
46	if( FAILED( hr ) )
47		return hr;
48
49	appState.findModelSource();
50
51	hr = SCREEN_MODEL;
52	while( true )
53	{
54		pfnDialog pfn = s_dialogs[ hr ];
55		if( nullptr == pfn )
56			return S_OK;
57		hr = pfn( appState );
58		if( FAILED( hr ) )
59			return hr;
60		if( hr == SCREEN_MODEL )
61			appState.model = nullptr;
62	}
63}