Removed the pause after plotting and added drawnow instead. Also added a MATLAB/Octave check for the specgram function