def write_stems(<EOL>audio,<EOL>filename,<EOL>rate=<NUM_LIT>,<EOL>bitrate=<NUM_LIT>,<EOL>codec=None,<EOL>ffmpeg_params=None<EOL>):
if int(stempeg.ffmpeg_version()[<NUM_LIT:0>]) < <NUM_LIT:3>:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>", UserWarning<EOL>)<EOL><DEDENT>if codec is None:<EOL><INDENT>avail = check_available_aac_encoders()<EOL>if avail is not None:<EOL><INDENT>if '<STR_LIT>' in avail:<EOL><INDENT>codec = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>codec = '<STR_LIT>'<EOL>warnings.warn("<STR_LIT>")<EOL><DEDENT><DEDENT>else:<EOL><INDENT>codec = '<STR_LIT>'<EOL>warnings.warn("<STR_LIT>")<EOL><DEDENT><DEDENT>tmps = [<EOL>tmp.NamedTemporaryFile(delete=False, suffix='<STR_LIT>')<EOL>for t in range(audio.shape[<NUM_LIT:0>])<EOL>]<EOL>if audio.shape[<NUM_LIT:1>] % <NUM_LIT> != <NUM_LIT:0>:<EOL><INDENT>warnings.warn(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>"<EOL>)<EOL><DEDENT>for k in range(audio.shape[<NUM_LIT:0>]):<EOL><INDENT>sf.write(tmps[k].name, audio[k], rate)<EOL><DEDENT>cmd = (<EOL>[<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>"<STR_LIT>", '<STR_LIT>' % (<NUM_LIT:16>),<EOL>"<STR_LIT>", '<STR_LIT>' % (<NUM_LIT:16>),<EOL>'<STR_LIT>', "<STR_LIT>" % rate,<EOL>'<STR_LIT>', "<STR_LIT>" % <NUM_LIT:2><EOL>] +<EOL>list(chain.from_iterable(<EOL>[['<STR_LIT>', i.name] for i in tmps]<EOL>)) +<EOL>list(chain.from_iterable(<EOL>[['<STR_LIT>', str(k)] for k, _ in enumerate(tmps)]<EOL>)) +<EOL>[<EOL>'<STR_LIT>',<EOL>'<STR_LIT>', codec,<EOL>'<STR_LIT>', "<STR_LIT>" % rate,<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT:error>'<EOL>] +<EOL>(['<STR_LIT>', str(bitrate)] if (bitrate is not None) else []) +<EOL>(ffmpeg_params if ffmpeg_params else []) +<EOL>[filename]<EOL>)<EOL>sp.call(cmd)<EOL>
Write stems from numpy Tensor

    Parameters
    ----------
    audio : array_like
        The tensor of Matrix of stems. The data shape is formatted as
        :code:`stems x channels x samples`.
    filename : str
        Output file_name of the stems file
    rate : int
        Output samplerate. Defaults to 44100 Hz.
    bitrate : int
        AAC Bitrate in Bits per second. Defaults to 256 Kbit/s
    codec : str
        AAC codec used. Defaults to `None` which automatically selects
        either `libfdk_aac` or `aac` in that order, determined by availability.
    ffmpeg_params : list(str)
        List of additional ffmpeg parameters

    Notes
    -----

    Output is written as 16bit/44.1 kHz