WavFileGenerator
Eliminates code duplication in WAV file generation across the speech module. Provides centralized WAV file creation, format conversion, metadata validation, and temporary file management.
All generation entry points validate AudioMeta up front via validateMetadata so that invalid sample rates, channel counts, or bit depths fail fast with a descriptive WavError rather than producing a corrupt WAV file.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
WavFileGenerator.type
Members list
Type members
Classlikes
Attributes
- Supertypes
-
trait LLMErrortrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Known subtypes
-
class WavGenerationFailedclass WavSaveFailed
Value members
Concrete methods
Create a temporary WAV file with the given prefix.
Create a temporary WAV file with the given prefix.
Attributes
Create GeneratedAudio from raw bytes with metadata, validating the metadata first.
Utility for creating WAV headers manually (advanced usage).
Utility for creating WAV headers manually (advanced usage).
Validates the metadata, then uses BinaryWriter typeclass instances for correct little-endian encoding. Returns a Result rather than throwing, per project convention.
Attributes
Create a managed temporary WAV file that gets deleted automatically.
Create a managed temporary WAV file that gets deleted automatically.
Attributes
Read a WAV file and return GeneratedAudio, parsing actual RIFF/WAV header fields.
Read a WAV file and return GeneratedAudio, parsing actual RIFF/WAV header fields.
The parsed metadata is validated via validateMetadata so that a malformed or non-PCM file is rejected with a descriptive error rather than yielding garbage metadata.
WAV header layout (little-endian): Offset 22: NumChannels (Short) Offset 24: SampleRate (Int) Offset 34: BitsPerSample (Short) Offset 44+: audio data
Attributes
Save GeneratedAudio as a WAV file using ManagedResource (eliminates duplication from AudioIO.saveWav).
Save GeneratedAudio as a WAV file using ManagedResource (eliminates duplication from AudioIO.saveWav).
The audio metadata is validated before writing.
Attributes
Save raw PCM data as a WAV file (eliminates duplication from AudioIO.saveRawPcm16).
Save raw PCM data as a WAV file (eliminates duplication from AudioIO.saveRawPcm16).
Metadata validation happens once inside saveAsWav to avoid double validation.
Attributes
Validate AudioMeta before it is used to generate or read a WAV file.
Validate AudioMeta before it is used to generate or read a WAV file.
Enforces that the sample rate is positive, the channel count is within [1,MaxChannels], and the bit depth is one of SupportedBitDepths.
Attributes
- Returns
-
the unchanged
metaon success, or a WavGenerationFailed describing the first violation
Write audio data to a temporary WAV file and return the path (eliminates duplication in TTS implementations).
Write audio data to a temporary WAV file and return the path (eliminates duplication in TTS implementations).
Attributes
Concrete fields
Maximum number of channels permitted (mono through 7.1 surround).
Maximum number of channels permitted (mono through 7.1 surround).
Attributes
Bit depths supported by this module's PCM WAV writer and reader.
Bit depths supported by this module's PCM WAV writer and reader.