add postprocessing package and create module for audio export
This commit is contained in:
@@ -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.")
|
||||
@@ -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}")
|
||||
Reference in New Issue
Block a user