feat(voice): автоконвертация WAV → OGG/Opus в telegram_send_voice#484
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#483
…voice Groq TTS already transcodes WAV → OGG/Opus through wavToOggOpus, but the voicePath branch of telegram_send_voice forwarded the file as-is. A WAV forwarded to GramJS reaches Telegram as a generic document instead of a voice note, which surfaced as the "unsupported audio format" failure. Detect the RIFF/WAVE magic bytes after path validation. When the input is a WAV, transcode in-process via the existing pure-JS Opus encoder (no ffmpeg needed), point GramJS at the OGG temp file, and mark it for the existing cleanup hook. OGG/Opus and other formats fall through unchanged so existing callers stay unaffected. Closes xlabtg#483
telegram_send_voice,
Working session summaryГотово. Что сделано: Реализация —
Тесты —
Проверки: PR This summary was automatically extracted from the AI working session output. |
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost: $3.145880📊 Context and tokens usage:
Total: (74 new + 94.1K cache writes + 4.2M cache reads) input tokens, 19.2K output tokens, $3.145880 cost 🤖 Models used:
📎 Log file uploaded as Gist (1644KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit df48231.
Описание
Закрывает #483.
Инструмент
telegram_send_voiceтеперь автоматически преобразует WAV‑файлы в OGG/Opus перед отправкой в Telegram. Раньше так делалось только в режиме TTS (черезwavToOggOpusв Groq‑провайдере); веткаvoicePathотправляла файл в Telegram «как есть», поэтому WAV-вход приходил как обычный документ, а не как голосовое сообщение, и возникала ошибкаunsupported audio format.Что изменилось
src/agent/tools/telegram/media/send-voice.tsvalidateReadPath(voicePath)читается первые 12 байт и проверяется WAV‑сигнатураRIFF…WAVE.wavToOggOpus(чисто JS Opus‑энкодер на WebAssembly, без зависимости от системногоffmpeg).tmpdir()/teleton-tts/<uuid>.ogg, путь подменяется и помечается для очистки в существующемfinally‑блоке.descriptionинструмента иvoicePath(упомянут WAV и авто‑конверсия).Покрытие тестами
src/agent/tools/telegram/media/__tests__/send-voice.test.ts:voicePathтранскодируется в OGG/Opus и попадает в GramJS как.ogg, временный файл удаляется после отправки.voicePathотправляется без вызоваwavToOggOpus(обратная совместимость).Failed to convert WAV voice file to OGG/Opus: …,sendFileне вызывается.Acceptance criteria
telegram_send_voiceпринимаетvoicePathилиtextи автоматически возвращает валидное OGG/Opus голосовое сообщение.opusscript. Системныйffmpegтакже не требуется.voicePathуже OGG/Opus — конверсия пропускается.Локальные проверки
npm run lint— без ошибок.npx tsc --noEmit— без ошибок (послеnpm run build:sdk).npm run format:check— все файлы соответствуют Prettier.npx vitest run— 210 файлов, 3522 тестов, все зелёные.Воспроизведение бага и проверка фикса
До фикса:
После фикса WAV прозрачно перекодируется в OGG/Opus, и Telegram принимает его как voice note. См. тест
auto-converts a WAV file passed via voicePath into OGG/Opus before sending.Fixes #483