Tom8266
871b932785
fix: detect Tencent SILK (\x02 prefix) in audio magic bytes to avoid ffmpeg failure (#8009)
* fix: detect Tencent SILK (\x02 prefix) in audio magic bytes to avoid ffmpeg failure
QQ official bot sends voice in Tencent SILK format (leading \x02 byte before
#!SILK_V3 magic). _get_audio_magic_type() had two off-by-one slice errors:
1. Standard SILK: header[:8] vs b'#!SILK_V3' (8 != 9 bytes) — never matched
2. Tencent SILK: not detected at all
Fixes:
- Standard SILK: header[:9] == b'#!SILK_V3' (correct 9-byte slice)
- Tencent SILK: header[:1] == b"\x02" and header[1:10] == b'#!SILK_V3'
- ensure_wav() routes detected silk to tencent_silk_to_wav()
Before: QQ voice → ffmpeg → 'Invalid data found'
After: QQ voice → magic detects silk → tencent_silk_to_wav → WAV OK
* refactor: use startswith() for SILK magic byte detection
Replace manual slice comparisons with startswith() — cleaner, less
error-prone, and immune to off-by-one slice errors.
Suggested by: sourcery-ai
2026-05-16 01:20:52 +08:00
..
2026-03-01 17:01:23 +09:00
2026-05-08 15:30:52 +08:00
2026-02-23 20:21:30 +08:00
2026-04-11 17:01:54 +08:00
2026-05-12 23:46:57 +08:00
2025-10-01 21:29:15 +08:00
2026-03-01 12:31:38 +09:00
2026-04-28 21:10:19 +09:00
2026-03-01 16:10:35 +09:00
2026-04-28 21:10:19 +09:00
2026-03-01 19:11:31 +09:00
2025-12-01 18:12:39 +08:00
2026-02-01 17:42:08 +08:00
2026-02-10 16:42:43 +09:00
2026-03-01 17:01:23 +09:00
2026-05-14 09:00:16 +08:00
2026-02-10 16:42:43 +09:00
2026-02-09 00:22:24 +08:00
2026-05-16 01:20:52 +08:00
2026-05-06 09:02:35 +08:00
2026-03-01 12:31:38 +09:00
2026-05-02 12:46:34 +08:00
2025-11-01 13:26:19 +08:00
2026-04-28 21:10:19 +09:00
2025-12-15 16:50:44 +08:00
2026-02-12 23:42:29 +09:00
2026-04-10 17:08:10 +09:00
2026-03-07 21:42:56 +09:00
2026-03-09 01:00:13 +09:00
2026-02-09 00:22:24 +08:00
2026-02-09 00:22:24 +08:00
2026-03-23 09:33:37 +08:00
2026-02-12 23:42:29 +09:00
2026-02-12 01:04:48 +08:00
2026-02-12 01:04:48 +08:00
2026-02-03 10:24:41 +08:00
2025-12-09 14:13:47 +08:00
2026-02-15 17:43:36 +08:00