pub struct AudioSamples {
pub samples: Vec<f32>,
pub sample_rate: u32,
pub channels: u16,
}Expand description
Raw audio samples produced by TTS synthesis.
Fields§
§samples: Vec<f32>Raw PCM samples as f32 in range [-1.0, 1.0].
sample_rate: u32Sample rate in Hz (e.g. 24000).
channels: u16Number of audio channels (always 1 for mono).
Implementations§
Source§impl AudioSamples
impl AudioSamples
Sourcepub fn duration_secs(&self) -> f32
pub fn duration_secs(&self) -> f32
Duration of the audio in seconds.
Sourcepub fn from_wav_bytes(bytes: &[u8]) -> Result<Self, TtsError>
pub fn from_wav_bytes(bytes: &[u8]) -> Result<Self, TtsError>
Decode a WAV file from bytes.
Supports RIFF/WAVE PCM integer data (8/16/24/32-bit) and 32-bit float. Multi-channel audio is downmixed to mono to match the library’s output convention.
Sourcepub fn from_wav_file(path: impl AsRef<Path>) -> Result<Self, TtsError>
pub fn from_wav_file(path: impl AsRef<Path>) -> Result<Self, TtsError>
Decode a WAV file from disk.
Sourcepub fn from_audio_stream<R>(stream: R) -> Result<Self, TtsError>
pub fn from_audio_stream<R>(stream: R) -> Result<Self, TtsError>
Decode a WAV or MP3 stream into mono PCM samples.
The input format is auto-detected. WAV is decoded directly and MP3 is decoded with the built-in MP3 decoder.
Sourcepub fn from_audio_bytes(bytes: &[u8]) -> Result<Self, TtsError>
pub fn from_audio_bytes(bytes: &[u8]) -> Result<Self, TtsError>
Decode a WAV or MP3 byte buffer into mono PCM samples.
Sourcepub fn from_audio_file(path: impl AsRef<Path>) -> Result<Self, TtsError>
pub fn from_audio_file(path: impl AsRef<Path>) -> Result<Self, TtsError>
Decode a WAV or MP3 file from disk.
Sourcepub fn denoise_audio_stream<R>(
stream: R,
options: DenoiseOptions,
) -> Result<Self, TtsError>
pub fn denoise_audio_stream<R>( stream: R, options: DenoiseOptions, ) -> Result<Self, TtsError>
Decode a WAV or MP3 stream and apply speech-focused denoising.
Sourcepub fn denoise_audio_bytes(
bytes: &[u8],
options: DenoiseOptions,
) -> Result<Self, TtsError>
pub fn denoise_audio_bytes( bytes: &[u8], options: DenoiseOptions, ) -> Result<Self, TtsError>
Decode a WAV or MP3 byte buffer and apply speech-focused denoising.
Sourcepub fn denoise_speech(&self, options: DenoiseOptions) -> Self
pub fn denoise_speech(&self, options: DenoiseOptions) -> Self
Apply speech-focused denoising to the current audio samples.
This is a classical DSP pass, not a learned source-separation model. It works best on mono spoken audio with steady background noise or music.
Trait Implementations§
Source§impl Clone for AudioSamples
impl Clone for AudioSamples
Source§fn clone(&self) -> AudioSamples
fn clone(&self) -> AudioSamples
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AudioSamples
impl RefUnwindSafe for AudioSamples
impl Send for AudioSamples
impl Sync for AudioSamples
impl Unpin for AudioSamples
impl UnsafeUnpin for AudioSamples
impl UnwindSafe for AudioSamples
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more