<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def pitch_contour(times, frequencies, fs, amplitudes=None, function=np.sin,
                  length=None, kind='linear'):
    '''Sonify a pitch contour.

    Parameters
    ----------
    times : np.ndarray
        time indices for each frequency measurement, in seconds

    frequencies : np.ndarray
        frequency measurements, in Hz.
        Non-positive measurements will be interpreted as un-voiced samples.

    fs : int
        desired sampling rate of the output signal

    amplitudes : np.ndarray
        amplitude measurments, nonnegative
        defaults to ``np.ones((length,))``

    function : function
        function to use to synthesize notes, should be :math:`2\pi`-periodic

    length : int
        desired number of samples in the output signal,
        defaults to ``max(times)*fs``

    kind : str
        Interpolation mode for the frequency and amplitude values.
        See: ``scipy.interpolate.interp1d`` for valid settings.

    Returns
    -------
    output : np.ndarray
        synthesized version of the pitch contour
    '''

    fs = float(fs)

    if length is None:
        length = int(times.max() * fs)

    # Squash the negative frequencies.
    # wave(0) = 0, so clipping here will un-voice the corresponding instants
    frequencies = np.maximum(frequencies, 0.0)

    # Build a frequency interpolator
    f_interp = interp1d(times * fs, 2 * np.pi * frequencies / fs, kind=kind,
                        fill_value=0.0, bounds_error=False, copy=False)

    # Estimate frequency at sample points
    f_est = f_interp(np.arange(length))

    if amplitudes is None:
        a_est = np.ones((length, ))
    else:
        # build an amplitude interpolator
        a_interp = interp1d(
            times * fs, amplitudes, kind=kind,
            fill_value=0.0, bounds_error=False, copy=False)
        a_est = a_interp(np.arange(length))

    # Sonify the waveform
    return a_est * function(np.cumsum(f_est))