From 348c0ad9530e5f4ccfc229a1586bbfc1021705f2 Mon Sep 17 00:00:00 2001 From: Konstantin Date: Fri, 3 Feb 2023 14:46:13 +0100 Subject: C++ console example now outputs text files when asked --- Examples/main/main.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'Examples/main/main.cpp') diff --git a/Examples/main/main.cpp b/Examples/main/main.cpp index d76bfc8..88ddc6d 100644 --- a/Examples/main/main.cpp +++ b/Examples/main/main.cpp @@ -5,6 +5,7 @@ #include "miscUtils.h" #include #include +#include "textWriter.h" using namespace Whisper; #define STREAM_AUDIO 1 @@ -286,9 +287,31 @@ int wmain( int argc, wchar_t* argv[] ) #endif if( FAILED( hr ) ) { - fwprintf( stderr, L"%s: failed to process audio\n", argv[ 0 ] ); + printError( "Unable to process audio", hr ); return 10; } + + if( params.output_txt ) + { + bool timestamps = !params.no_timestamps; + hr = writeText( context, fname.c_str(), timestamps ); + if( FAILED( hr ) ) + printError( "Unable to produce the text file", hr ); + } + + if( params.output_srt ) + { + hr = writeSubRip( context, fname.c_str() ); + if( FAILED( hr ) ) + printError( "Unable to produce the text file", hr ); + } + + if( params.output_vtt ) + { + hr = writeWebVTT( context, fname.c_str() ); + if( FAILED( hr ) ) + printError( "Unable to produce the text file", hr ); + } } context->timingsPrint(); -- cgit v1.2.3