From: Daniel Bevenius Date: Wed, 14 May 2025 17:21:48 +0000 (+0200) Subject: examples : add --print-confidence option to cli (whisper/3150) X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=1ec637d56251638e45ab0e1da4d93ea9b8a6a072;p=pkg%2Fggml%2Fsources%2Fggml examples : add --print-confidence option to cli (whisper/3150) * examples : add --print-confidence option to cli This commit adds a new command-line option `--print-confidence` to the whisper-cli. When enabled, this option prints the confidence level of each token in the transcribed text using ANSI formatting codes. The confidence levels are represented using different styles: ```console main: confidence: highlighted (low confidence), underlined (medium), dim (high confidence) ``` Refs: https://github.com/ggml-org/whisper.cpp/issues/3135 --- diff --git a/examples/common.h b/examples/common.h index 1aa76381..8f99df7d 100644 --- a/examples/common.h +++ b/examples/common.h @@ -294,6 +294,26 @@ const std::vector k_colors = { set_xterm256_foreground( 78, 178, 101), }; +// ANSI formatting codes +static std::string set_inverse() { + return "\033[7m"; +} + +static std::string set_underline() { + return "\033[4m"; +} + +static std::string set_dim() { + return "\033[2m"; +} + +// Style scheme for different confidence levels +const std::vector k_styles = { + set_inverse(), // Low confidence - inverse (highlighted) + set_underline(), // Medium confidence - underlined + set_dim(), // High confidence - dim +}; + // // Other utils //