Skip to content

Conversation

@OrelSokolov
Copy link
Contributor

PR: Add --verbose flag for colored logging

Summary

This PR adds a --verbose flag to whisper-cli that controls INFO level log visibility and adds colored terminal output for better readability.

Motivation

Currently, whisper-cli outputs all INFO level messages (model loading, memory allocation, etc.) which can clutter the output for users who only want the transcription results. At the same time, these messages are valuable for debugging and troubleshooting.

Solution

Add a --verbose / -v flag that:

  • ✅ Hides INFO level messages by default (quiet mode)
  • ✅ Shows INFO messages when --verbose is enabled
  • ✅ Always shows WARN and ERROR messages (regardless of verbose setting)
  • ✅ Adds color-coded output for better readability:
    • 🔴 Red for errors
    • 🟡 Yellow for warnings
    • 🔵 Cyan for info messages

Changes

CLI Interface (examples/cli/cli.cpp)

  • Added --verbose / -v flag parameter
  • Implemented cb_log_filter() callback that filters INFO messages based on verbose flag
  • Added colored output using termcolor library

Core Library (src/whisper.cpp)

  • Updated default log callback to support colored output
  • Improved error messages for backend buffer allocation failures

Build System

  • Added termcolor library via CMake FetchContent
  • Updated CMakeLists.txt files to link termcolor

Usage

# Quiet mode (default) - only shows warnings, errors, and results
./whisper-cli -m model.bin -f audio.wav

# Verbose mode - shows all INFO messages with colors
./whisper-cli -m model.bin -f audio.wav --verbose
./whisper-cli -m model.bin -f audio.wav -v

# Silent mode - no output except results (existing flag)
./whisper-cli -m model.bin -f audio.wav --no-prints

Examples

Default (Quiet) Output

 And so my fellow Americans, ask not what your country can do for you...

Verbose Output

whisper_init_from_file: loading model from 'model.bin'
whisper_model_load: n_vocab       = 51864
whisper_model_load: n_audio_ctx   = 1500
whisper_model_load: model size    = 147.37 MB
...
 And so my fellow Americans, ask not what your country can do for you...

With Errors (Always Shown)

ERROR: failed to allocate backend buffer
ERROR: not enough memory available - try using a smaller model

Benefits

  1. Cleaner default output - Users get transcriptions without log clutter
  2. Better debugging - Developers can enable verbose mode when needed
  3. Improved readability - Color-coded messages make it easier to spot issues
  4. Backward compatible - Default behavior only improved, no breaking changes

Dependencies

  • termcolor - Header-only library for colored terminal output (v2.1.0)
    • MIT licensed
    • Cross-platform (Windows, Linux, macOS)
    • No runtime dependencies

- Add termcolor library dependency via FetchContent
- Add --verbose/-v flag to whisper-cli to control INFO level messages
- Implement log filtering callback that hides INFO messages unless verbose is enabled
- Add colored output to log messages (red for errors, yellow for warnings, cyan for info)
- Add better error handling for backend buffer allocation failures
- INFO messages are now hidden by default, only shown with --verbose flag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant