<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def write(series, output, scale=None):
 """Write a `TimeSeries` to a WAV file Parameters series : `TimeSeries` the series to write output : `file`, `str` the file object or filename to write to scale : `float`, optional the factor to apply to scale the data to (-1.0, 1.0), pass `scale=1` to not apply any scale, otherwise the data will be auto-scaled See also -------- scipy.io.wavfile.write for details on how the WAV file is actually written Examples -------- """

    fsamp = int(series.sample_rate.decompose().value)
    if scale is None:
        scale = 1 / numpy.abs(series.value).max()
    data = (series.value * scale).astype('float32')
    return wavfile.write(output, fsamp, data)