文字轉語音
平台無關的 tts package 會將文字轉成 OGG/OPUS bytes,供 Telegram 與 Discord 的 upload helper 使用。
API
ogg, err := tts.Get(ctx, apiKey, "Hello")
Get 拒絕空 API key 或 text,並要求 PATH 中存在 ffmpeg。它會請求 Gemini model gemini-3.1-flash-tts-preview、使用 Kore prebuilt voice,解碼回傳的 PCM 音訊,再呼叫 ffmpeg 產生 mono 24 kHz、32k bitrate 的 OGG/OPUS。轉換後會刪除暫存檔。
平台整合
telegram.SendVoice 將 bytes 上傳為 voice.ogg。discord.SendVoice 將同樣格式上傳為 audio/ogg attachment;Discord 呈現為 audio attachment,不是原生 waveform voice message。