audio_enhancer.enhancer
audio_enhancer.enhancer
audio_enhancer.enhancer.AudioEnhancer
A facade and Singleton for the audio enhancement system.
Provides a simplified, high-level interface to the underlying audio loading, exporting, and pipeline building components.
Example
enhancer = AudioEnhancer.get_instance() audio = enhancer.load_audio("input.wav") builder = enhancer.get_builder() pipeline = builder.add_step(SpectralGatingNoiseReducer()).build() enhanced = pipeline.process(audio) enhancer.export_audio(enhanced, "output.wav", "wav")
Source code in audio_enhancer/enhancer.py
audio_enhancer.enhancer.AudioEnhancer.export_audio(audio, file_path, format)
Exports an AudioSegment to a file with the specified format.
This hides the details of the exporter module and formats support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
audio
|
AudioSegment
|
The audio segment to export. |
required |
file_path
|
str
|
The destination file path. |
required |
format
|
str
|
The desired output format (e.g., 'mp3', 'wav', 'flac'). |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If the audio export fails. |
Source code in audio_enhancer/enhancer.py
audio_enhancer.enhancer.AudioEnhancer.generate_report(original_path, processed_path, output_dir='.reports')
Generate visual comparison reports for processed audio.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
original_path
|
str
|
Path to the original audio file. |
required |
processed_path
|
str
|
Path to the processed audio file. |
required |
output_dir
|
str
|
Directory where comparison reports will be stored. |
'.reports'
|
Returns:
| Type | Description |
|---|---|
list
|
list[Path]: List of paths to the generated report files. |
Source code in audio_enhancer/enhancer.py
audio_enhancer.enhancer.AudioEnhancer.get_builder()
Returns a new PipelineBuilder instance.
Integrates the Builder pattern into the facade to allow chaining steps.
Returns:
| Name | Type | Description |
|---|---|---|
PipelineBuilder |
PipelineBuilder
|
A new pipeline builder instance. |
Source code in audio_enhancer/enhancer.py
audio_enhancer.enhancer.AudioEnhancer.get_instance()
classmethod
Provides a global access point to the Singleton instance.
Returns:
| Name | Type | Description |
|---|---|---|
AudioEnhancer |
AudioEnhancer
|
The active singleton instance. |
audio_enhancer.enhancer.AudioEnhancer.load_audio(file_path)
Loads an audio file from disk into an AudioSegment.
This hides the detailed loader implementations and formats support.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the input audio file. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
AudioSegment |
AudioSegment
|
The loaded pydub AudioSegment. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
Exception
|
If pydub or ffmpeg fails to decode the file. |