# Path: mugen/exceptions.py
# class ParameterError(MugenError):
#     """
#     Exception class for mal-formed inputs
#     """
# 
#     pass
# 
# Path: mugen/utilities/system.py
# def use_temporary_file_fallback(path_var: str, extension: str):
#     """
#     Decorator to set path_var to a temporary file path if it is None. Does not create the file.
# 
#     Parameters
#     ----------
#     path_var
#         A variable expecting a file path
# 
#     extension
#         extension for the temporary file
#     """
# 
#     def _use_temporary_file_path(path_variable):
#         return path_variable or generate_temp_file_path(extension)
# 
#     return preprocess_args(_use_temporary_file_path, [path_var])


from typing import List, Optional, Union
from mugen.exceptions import ParameterError
from mugen.utilities.system import use_temporary_file_fallback
import librosa
import numpy
import soundfile



MARKED_AUDIO_EXTENSION = ".wav"


@use_temporary_file_fallback("output_path", MARKED_AUDIO_EXTENSION)
def create_marked_audio_file(
    mark_locations: Union[List[float], numpy.ndarray],
    output_path: Optional[str] = None,
    *,
    audio_file: Optional[str] = None,
    duration: float = None
):
    if audio_file:
        y, sr = librosa.load(audio_file)
        marked_audio = librosa.core.clicks(times=mark_locations, sr=sr, length=len(y))
        marked_audio = y + marked_audio
    elif duration:
        sr = 22050
        marked_audio = librosa.core.clicks(

# Path: mugen/exceptions.py
# class ParameterError(MugenError):
#     """
#     Exception class for mal-formed inputs
#     """
# 
#     pass
# 
# Path: mugen/utilities/system.py
# def use_temporary_file_fallback(path_var: str, extension: str):
#     """
#     Decorator to set path_var to a temporary file path if it is None. Does not create the file.
# 
#     Parameters
#     ----------
#     path_var
#         A variable expecting a file path
# 
#     extension
#         extension for the temporary file
#     """
# 
#     def _use_temporary_file_path(path_variable):
#         return path_variable or generate_temp_file_path(extension)
# 
#     return preprocess_args(_use_temporary_file_path, [path_var])


# Path: mugen/audio/utilities.py
from typing import List, Optional, Union
from mugen.exceptions import ParameterError
from mugen.utilities.system import use_temporary_file_fallback
import librosa
import numpy
import soundfile




MARKED_AUDIO_EXTENSION = ".wav"


@use_temporary_file_fallback("output_path", MARKED_AUDIO_EXTENSION)
def create_marked_audio_file(
    mark_locations: Union[List[float], numpy.ndarray],
    output_path: Optional[str] = None,
    *,
    audio_file: Optional[str] = None,
    duration: float = None
):
    if audio_file:
        y, sr = librosa.load(audio_file)
        marked_audio = librosa.core.clicks(times=mark_locations, sr=sr, length=len(y))
        marked_audio = y + marked_audio
    elif duration:
        sr = 22050
        marked_audio = librosa.core.clicks(

            times=mark_locations, sr=sr, length=int(sr * duration)