package server import ( "bytes" "context" "encoding/json" "fmt" "io" "net/http" "strconv" "strings" "time" ) // ─── Audio generation via Kokoro /v1/audio/speech ──────────────────────────── // // handleAudioGenerate handles POST /api/audio/{slug}/{n}. // // It calls Kokoro's POST /v1/audio/speech with return_download_link=true. // Kokoro generates the audio, saves it to its own temp storage, and returns // the download filename in the X-Download-Path response header. // We cache that filename (in memory, keyed by slug/chapter/voice) and // return a proxy URL that the browser sets as audio.src. // // TTS is always generated at speed 1.0; playback speed is controlled // client-side via the