add postprocessing package and create module for audio export

This commit is contained in:
Joel Mathew Thomas
2025-01-28 20:33:57 +05:30
parent 3914b2c5ba
commit 2982aaaafd
2 changed files with 29 additions and 0 deletions
+12
View File
@@ -0,0 +1,12 @@
# __init__.py
import logging
from datetime import datetime
# Configure logging
logging.basicConfig(
format='%(asctime)s : %(message)s',
level = logging.INFO
)
logging.info("freq-split-enhance/postprocessing package has been imported.")
+17
View File
@@ -0,0 +1,17 @@
import soundfile as sf
def export_audio(audio, output_path, sr):
"""
Save a NumPy audio array to a specified audio file.
Args:
audio (numpy.ndarray): The audio data to be saved.`
output_path (str): The path where the audio file should be saved.
sr (int): The sampling rate of the audio.
"""
try:
sf.write(output_path, audio, sr)
print(f"Audio saved to {output_path}")
except Exception as e:
print(f"Error saving audio: {e}")