Spectroscopy and spectral imaging have widespread applications in many scientific fields. Deep learning techniques have achieved many successes in recent years across numerous domains. However, the application of deep learning to spectral data remains a complex task due to the need for tailored augmentation routines, specific architectures for spectral data and significant memory requirements. Here we present spectrai, a comprehensive open-source deep learning framework and Python/MATLAB package designed to facilitate the training of neural networks on spectral data. spectrai provides numerous built-in spectral data pre-processing and augmentation methods, neural networks for spectral data including spectral (image) denoising, spectral (image) classification, spectral image segmentation and spectral image super-resolution. spectrai includes both command line and graphical user interface (GUI) tools designed to assist users with model and hyperparameter decisions for a wide range of applications. We demonstrate three case studies of spectral denoising, spectral segmentation and super-resolution. By providing baseline implementations of these functions, spectrai enables wider use of deep learning in spectroscopy and spectral imaging.