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
1be5537
master
1using Whisper ; 2 3namespace MicrophoneCS 4{ 5static class Program 6{ 7static int Main ( string [] args ) 8{ 9try 10{ 11CommandLineArgs cla ; 12try 13{ 14cla = new CommandLineArgs ( args ); 15} 16catch ( OperationCanceledException ) 17{ 18return 1 ; 19} 20const eLoggerFlags loggerFlags = eLoggerFlags . UseStandardError | eLoggerFlags . SkipFormatMessage ; 21Library . setLogSink ( eLogLevel . Debug , loggerFlags ); 22 23using iMediaFoundation mf = Library . initMediaFoundation (); 24CaptureDeviceId [] devices = mf . listCaptureDevices () ?? 25throw new ApplicationException ( "This computer has no audio capture devices" ); 26 27if ( cla . listDevices ) 28{ 29for ( int i = 0 ; i < devices . Length ; i ++ ) 30Console . WriteLine ( "#{0}: {1}" , i , devices [ i ]. displayName ); 31return 0 ; 32} 33if ( cla . captureDeviceIndex < 0 || cla . captureDeviceIndex >= devices . Length ) 34throw new ApplicationException ( $"Capture device index is out of range; the valid range is [ 0 .. { devices . Length - 1 } ]" ); 35 36sCaptureParams cp = new sCaptureParams (); 37if ( cla . diarize ) 38cp . flags |= eCaptureFlags . Stereo ; 39using iAudioCapture captureDev = mf . openCaptureDevice ( devices [ cla . captureDeviceIndex ], cp ); 40 41using iModel model = Library . loadModel ( cla . model ); 42using Context context = model . createContext (); 43cla . apply ( ref context . parameters ); 44 45CaptureThread thread = new CaptureThread ( cla , context , captureDev ); 46thread . join (); 47 48context . timingsPrint (); 49return 0 ; 50} 51catch ( Exception ex ) 52{ 53// Console.WriteLine( ex.Message ); 54Console . WriteLine ( ex . ToString () ); 55return ex . HResult ; 56} 57} 58} 59}