format_from_extension (tts/encode.rs)

kesha-voice-kit · rust/src/tts/encode.rs · rust · MIT
voice, Voice / Speech

Rust module that encodes f32 PCM samples into WAV, OGG/Opus, or FLAC formats for TTS output.

// Source: https://github.com/drakulavich/kesha-voice-kit | License: MIT | Copyright 2026 drakulavich
// Provided via justclaw.it.com; keep this notice with the code.
//! Output audio encoding: f32 PCM samples → wire bytes.
//!
//! Closes #223. Adds OGG/Opus (the format Telegram, WhatsApp, Signal, and
//! Discord render as native voice messages) and FLAC (lossless, royalty-free,
//! browser-universal incl. Safari) alongside the original WAV. Keeps the door
//! open for `mp3` / `raw-pcm` later.

use std::str::FromStr;

#[cfg(feature = "tts")]
use crate::audio::resample_mono;

use super::wav;

/// Wire format for [`encode`]. New variants live behind `--format` on the CLI;
/// values are spelled in kebab-case to match `clap` parsing.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub e

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key