Distribute and run LLMs with a single file.
C++ cross-platformggufllama-cpplocal-ailocal-inferencelocal-llmopen-source-aisingle-file-executablespeech-to-text
Use colorblind friendly TTY colors in whisperfile
Justine Tunney74500346ad67
diff --git a/whisper.cpp/common.h b/whisper.cpp/common.hindex 8a425fe4..9b063557 100644--- a/whisper.cpp/common.h+++ b/whisper.cpp/common.h@@ -167,12 +167,43 @@ void sam_print_usage(int argc, char ** argv, const sam_params & params);// Terminal utils//--// Terminal color map. 10 colors grouped in ranges [0.0, 0.1, ..., 0.9]-// Lowest is red, middle is yellow, highest is green.+#define SQR(X) ((X) * (X))+#define UNCUBE(x) x < 48 ? 0 : x < 115 ? 1 : (x - 35) / 40++/**+ * Quantizes 24-bit RGB to xterm256 code range [16,256).+ */+static int rgb2xterm256(int r, int g, int b) {+ unsigned char cube[] = {0, 0137, 0207, 0257, 0327, 0377};+ int av, ir, ig, ib, il, qr, qg, qb, ql;+ av = r * .299 + g * .587 + b * .114 + .5;+ ql = (il = av > 238 ? 23 : (av - 3) / 10) * 10 + 8;+ qr = cube[(ir = UNCUBE(r))];+ qg = cube[(ig = UNCUBE(g))];+ qb = cube[(ib = UNCUBE(b))];+ if (SQR(qr - r) + SQR(qg - g) + SQR(qb - b) <=+ SQR(ql - r) + SQR(ql - g) + SQR(ql - b))+ return ir * 36 + ig * 6 + ib + 020;+ return il + 0350;+}++static std::string set_xterm256_foreground(int r, int g, int b) {+ int x = rgb2xterm256(r, g, b);+ std::ostringstream oss;+ oss << "\033[38;5;" << x << "m";+ return oss.str();+}++// Lowest is red, middle is yellow, highest is green. Color scheme from+// Paul Tol; it is colorblind friendly https://personal.sron.nl/~pault/const std::vector<std::string> k_colors = {- "\033[38;5;196m", "\033[38;5;202m", "\033[38;5;208m", "\033[38;5;214m", "\033[38;5;220m",- "\033[38;5;226m", "\033[38;5;190m", "\033[38;5;154m", "\033[38;5;118m", "\033[38;5;82m",+ set_xterm256_foreground(220, 5, 12),+ set_xterm256_foreground(232, 96, 28),+ set_xterm256_foreground(241, 147, 45),+ set_xterm256_foreground(246, 193, 65),+ set_xterm256_foreground(247, 240, 86),+ set_xterm256_foreground(144, 201, 135),+ set_xterm256_foreground( 78, 178, 101),};//