Global Utilities
The olaverse.utils module exposes global constants and basic utility functions used throughout the library.
Constants & Formatting
olaverse.utils.format_currency(amount, symbol='$')
Format a number or string as a generic currency. e.g. format_currency(1500, "$") -> $1,500.00
olaverse.utils.CURRENCIES = {'USD': '$', 'EUR': '€', 'GBP': '£', 'JPY': '¥', 'CNY': '¥', 'NGN': '₦', 'ZAR': 'R', 'INR': '₹', 'CAD': '$', 'AUD': '$', 'BRL': 'R$'}
module-attribute
olaverse.utils.CONTINENTS = {'AF': 'Africa', 'AS': 'Asia', 'EU': 'Europe', 'NA': 'North America', 'SA': 'South America', 'OC': 'Oceania', 'AN': 'Antarctica'}
module-attribute
Audio I/O
Standard read/write wrappers for managing .wav files.
olaverse.utils.load_audio(input_path)
Load an audio waveform from a .wav file.
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
(sample_rate, waveform) |
olaverse.utils.save_audio(waveform, sample_rate, output_path)
Save a generated audio waveform to a .wav file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
waveform
|
1D numpy array representing the audio signal. |
required | |
sample_rate
|
int
|
The sampling rate (e.g., 22050 or 24000). |
required |
output_path
|
str
|
Path to save the audio file. |
required |