<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Sine model Analysis/Synthesis - MusicBricks Tutorial
Introduction
This tutorial will guide you through some tools for performing spectral analysis and synthesis using the Essentia library (http
Step1:  After importing Essentia library, let's import other numerical and plotting tools
Step2:  Define the parameters of the STFT workflow
Step3:  Specify input and output audio filenames
Step4:  Define algorithm chain for frame-by-frame process
Step5:  Now we set the algorithm network and store the processed audio samples in the output file
Step6:  Finally we run the process that will store an output file in a WAV file
<ASSISTANT_TASK:>
Python Code:
# import essentia in streaming mode
import essentia
import essentia.streaming as es
Explanation: Sine model Analysis/Synthesis - MusicBricks Tutorial
Introduction
This tutorial will guide you through some tools for performing spectral analysis and synthesis using the Essentia library (http://www.essentia.upf.edu). 
This algorithm shows how to analyze the input signal, and resynthesize it again, allowing to apply new transformations directly on the spectral domain.
You should first install the Essentia library with Python bindings. Installation instructions are detailed here: http://essentia.upf.edu/documentation/installing.html . 
Processing steps
End of explanation
# import matplotlib for plotting
import matplotlib.pyplot as plt
import numpy as np
Explanation: After importing Essentia library, let's import other numerical and plotting tools
End of explanation
# algorithm parameters
params = { 'frameSize': 2048, 'hopSize': 512, 'startFromZero': False, 'sampleRate': 44100, \
          'maxnSines': 100,'magnitudeThreshold': -74,'minSineDur': 0.02,'freqDevOffset': 10, \
          'freqDevSlope': 0.001}
Explanation: Define the parameters of the STFT workflow
End of explanation
inputFilename = 'singing-female.wav'
outputFilename = 'singing-female-sindemodel.wav'
# create an audio loader and import audio file
out = np.array(0)
loader = es.MonoLoader(filename = inputFilename, sampleRate = 44100)
pool = essentia.Pool()
Explanation: Specify input and output audio filenames
End of explanation
# algorithm instantation
fcut = es.FrameCutter(frameSize = params['frameSize'], hopSize = params['hopSize'], startFromZero =  False);
w = es.Windowing(type = "blackmanharris92");
fft = es.FFT(size = params['frameSize']);
smanal = es.SineModelAnal(sampleRate = params['sampleRate'], maxnSines = params['maxnSines'], magnitudeThreshold = params['magnitudeThreshold'], freqDevOffset = params['freqDevOffset'], freqDevSlope = params['freqDevSlope'])
smsyn = es.SineModelSynth(sampleRate = params['sampleRate'], fftSize = params['frameSize'], hopSize = params['hopSize'])
ifft = es.IFFT(size = params['frameSize']);
overl = es.OverlapAdd (frameSize = params['frameSize'], hopSize = params['hopSize'], gain = 1./params['frameSize'] );
awrite = es.MonoWriter (filename = outputFilename, sampleRate =  params['sampleRate']);
Explanation: Define algorithm chain for frame-by-frame process: 
FrameCutter -> Windowing -> FFT -> IFFT -> OverlapAdd -> AudioWriter
End of explanation
# analysis
loader.audio >> fcut.signal
fcut.frame >> w.frame
w.frame >> fft.frame
fft.fft >> smanal.fft
# synthesis
smanal.magnitudes >> smsyn.magnitudes
smanal.frequencies >> smsyn.frequencies
smanal.phases >> smsyn.phases
smsyn.fft >> ifft.fft
ifft.frame >> overl.frame
overl.signal >> awrite.audio
overl.signal >> (pool, 'audio')
Explanation: Now we set the algorithm network and store the processed audio samples in the output file
End of explanation
essentia.run(loader)
Explanation: Finally we run the process that will store an output file in a WAV file
End of explanation
<END_TASK>