* 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
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<std::string> k_styles = {
+ set_inverse(), // Low confidence - inverse (highlighted)
+ set_underline(), // Medium confidence - underlined
+ set_dim(), // High confidence - dim
+};
+
//
// Other utils
//