<s> '''<STR_LIT>''' <EOL> import jams <EOL> import librosa <EOL> import soundfile as psf <EOL> import jsonpickle <EOL> import six <EOL> from . version import version <EOL> __all__ = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> def jam_pack ( jam , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if not hasattr ( jam . sandbox , '<STR_LIT>' ) : <EOL> jam . sandbox . muda = jams . Sandbox ( history = [ ] , <EOL> state = [ ] , <EOL> version = dict ( muda = version , <EOL> librosa = librosa . __version__ , <EOL> jams = jams . __version__ , <EOL> pysoundfile = psf . __version__ ) ) <EOL> jam . sandbox . muda . update ( ** kwargs ) <EOL> return jam <EOL> def load_jam_audio ( jam_in , audio_file , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> if isinstance ( jam_in , jams . JAMS ) : <EOL> jam = jam_in <EOL> else : <EOL> jam = jams . load ( jam_in ) <EOL> y , sr = librosa . load ( audio_file , ** kwargs ) <EOL> return jam_pack ( jam , _audio = dict ( y = y , sr = sr ) ) <EOL> def save ( filename_audio , filename_jam , jam , strict = True , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> y = jam . sandbox . muda . _audio [ '<STR_LIT:y>' ] <EOL> sr = jam . sandbox . muda . _audio [ '<STR_LIT>' ] <EOL> psf . write ( filename_audio , y , sr , ** kwargs ) <EOL> jam . save ( filename_jam , strict = strict ) <EOL> def __reconstruct ( params ) : <EOL> '''<STR_LIT>''' <EOL> if isinstance ( params , dict ) : <EOL> if '<STR_LIT>' in params : <EOL> cls = params [ '<STR_LIT>' ] <EOL> data = __reconstruct ( params [ '<STR_LIT>' ] ) <EOL> return cls ( ** data ) <EOL> else : <EOL> data = dict ( ) <EOL> for key , value in six . iteritems ( params ) : <EOL> data [ key ] = __reconstruct ( value ) <EOL> return data <EOL> elif isinstance ( params , ( list , tuple ) ) : <EOL> return [ __reconstruct ( v ) for v in params ] <EOL> else : <EOL> return params <EOL> def serialize ( transform , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> params = transform . get_params ( ) <EOL> return jsonpickle . encode ( params , ** kwargs ) <EOL> def deserialize ( encoded , ** kwargs ) : <EOL> '''<STR_LIT>''' <EOL> params = jsonpickle . decode ( encoded , ** kwargs ) <EOL> return __reconstruct ( params ) </s>
