summaryrefslogtreecommitdiffstats
path: root/Examples/main/main.cpp
diff options
context:
space:
mode:
authorKonstantin <const@const.me>2023-02-03 14:46:13 +0100
committerKonstantin <const@const.me>2023-02-03 14:46:13 +0100
commit348c0ad9530e5f4ccfc229a1586bbfc1021705f2 (patch)
tree9a1629fd5615c4e0a7d652c6df5c4dee2cdcc44b /Examples/main/main.cpp
parentc869213e639f523752f5b41706486b320f994d1b (diff)
C++ console example now outputs text files when asked
Diffstat (limited to 'Examples/main/main.cpp')
-rw-r--r--Examples/main/main.cpp25
1 files changed, 24 insertions, 1 deletions
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 <array>
#include <atomic>
+#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();