Commit 2b30aca
committed
feat(audio): add whisper audio transcription; fix bugs; update docs and CI
Audio transcription:
- Add audio_model_transcribe() accepting TEXT (file path) or BLOB input
- Auto-detect audio format from file extension and magic bytes (WAV, MP3, FLAC)
- Convert audio to mono 16kHz PCM as required by Whisper
- Support 15 transcription options (language, translate, n_threads, temperature, etc.)
- Uncomment and register audio_model_load/audio_model_free functions
- Add 8 new unit tests covering transcription, options, error handling, and lifecycle
Bug fixes:
- Fix strncasecmp prefix-matching bug: add KEY_MATCHES macro that checks both
key length and case-insensitive match, replacing all 39 occurrences
- Fix wrong variable in logger call: warn_buf was formatted but buffer was passed
to ai_logger, logging raw option values instead of the warning message
- Fix NULL dereference in role_normalize when role is NULL
- Fix NULL dereference in llm_model_cls_label when label is NULL
- Fix potential buffer overflow in prompt_len underflow (negative-to-size_t wraparound)
- Fix uint16_t type mismatch in audio PCM functions: miniaudio writes unsigned int
(4 bytes) for channels, but uint16_t (2 bytes) was used, causing stack corruption
- Fix whisper params string lifetime: track default vs dynamically allocated strings
to avoid sqlite3_free on static string literals
- Fix PCM buffer free: use sqlite3_free instead of free for buffers allocated via
miniaudio's custom sqlite3_malloc allocator
- Remove redundant NULL assignment in buffer_destroy
Submodule updates:
- Update miniaudio from 0.11.22 to 0.11.25
- Update llama.cpp and whisper.cpp submodules
CI (main.yml):
- Add whisper model and audio test file download with caching
- Rename download-model job to download-models
- Cache whisper model (ggml-tiny.bin) and audio test WAV (jfk.wav) across runs
Makefile:
- Add whisper model and audio test file download targets
- Pass --whisper-model and --audio arguments to unit test binary
Documentation:
- API.md: add llm_chat_system_prompt, audio_model_load, audio_model_free,
audio_model_transcribe with full options table; fix version and typos
- README.md: move Getting Started after Features; add examples for embedding
generation, chat, and audio transcription; add Audio Transcription feature;
update description to reflect shipped audio support
Version bump: 0.7.59 → 0.9.01 parent 7de5728 commit 2b30aca
File tree
12 files changed
+1879
-420
lines changed- .github/workflows
- modules
- src
- tests/c
12 files changed
+1879
-420
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
18 | 24 | | |
19 | 25 | | |
20 | | - | |
| 26 | + | |
21 | 27 | | |
22 | | - | |
23 | | - | |
24 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
25 | 35 | | |
26 | 36 | | |
27 | | - | |
| 37 | + | |
28 | 38 | | |
29 | 39 | | |
30 | 40 | | |
31 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
32 | 44 | | |
33 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
34 | 48 | | |
35 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
36 | 52 | | |
37 | | - | |
38 | | - | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
39 | 58 | | |
40 | 59 | | |
41 | | - | |
| 60 | + | |
42 | 61 | | |
43 | 62 | | |
44 | 63 | | |
45 | | - | |
| 64 | + | |
46 | 65 | | |
47 | 66 | | |
48 | | - | |
49 | | - | |
50 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
51 | 70 | | |
52 | 71 | | |
53 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
54 | 101 | | |
55 | | - | |
| 102 | + | |
56 | 103 | | |
57 | 104 | | |
58 | 105 | | |
| |||
150 | 197 | | |
151 | 198 | | |
152 | 199 | | |
153 | | - | |
154 | | - | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
155 | 205 | | |
156 | 206 | | |
157 | 207 | | |
158 | 208 | | |
159 | | - | |
160 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
161 | 223 | | |
162 | 224 | | |
163 | 225 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
706 | 706 | | |
707 | 707 | | |
708 | 708 | | |
709 | | - | |
| 709 | + | |
710 | 710 | | |
711 | 711 | | |
712 | 712 | | |
| |||
716 | 716 | | |
717 | 717 | | |
718 | 718 | | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
719 | 825 | | |
720 | 826 | | |
721 | 827 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
47 | 56 | | |
48 | 57 | | |
49 | 58 | | |
| |||
88 | 97 | | |
89 | 98 | | |
90 | 99 | | |
91 | | - | |
| 100 | + | |
| 101 | + | |
92 | 102 | | |
93 | 103 | | |
94 | 104 | | |
| |||
102 | 112 | | |
103 | 113 | | |
104 | 114 | | |
105 | | - | |
| 115 | + | |
106 | 116 | | |
107 | 117 | | |
108 | 118 | | |
| |||
235 | 245 | | |
236 | 246 | | |
237 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
238 | 256 | | |
239 | 257 | | |
240 | | - | |
| 258 | + | |
241 | 259 | | |
242 | 260 | | |
243 | 261 | | |
244 | 262 | | |
245 | 263 | | |
246 | 264 | | |
247 | | - | |
| 265 | + | |
248 | 266 | | |
249 | 267 | | |
250 | 268 | | |
| |||
0 commit comments