Saving temporary file for plotting audio waveform
Instead of saving file you can create io.BytesIO object and use it instead of file.

Also

    def allowed_file(filename):
      return (
          '.' in filename
          and os.splitext(filename)[1].lower() in ALLOWED_EXTENSIONS
      )


Also maybe you should check content-type header and not only extension.