def _generate_temp_spectral(self, track, filenames): assert len(filenames) == 2 track_path = os.path.join(self.temp_dir, track.temp_filename) logger.info('Generating spectrals for {0}'.format(track.temp_filename)) full_title = '{0} Full'.format(os.path.splitext(track.filename)[0]) zoom_title = '{0} Zoom'.format(os.path.splitext(track.filename)[0]) ensure_file_dir_exists(filenames[0]) ensure_file_dir_exists(filenames[0]) args = [ 'sox', track_path, '-n', 'remix', '1', 'spectrogram', '-x', '3000', '-y', '513', '-w', 'Kaiser', '-t', full_title, '-o', filenames[0] ] if self.high_color: args.append('-h') if call([q_enc(a) for a in args]) != 0: raise Exception('sox returned non-zero') assert track.duration >= 4, 'Track is shorter than 4 seconds' zoom_start = time_text(min(40, track.duration - 4)) args = [ 'sox', track_path, '-n', 'remix', '1', 'spectrogram', '-x', '3000', '-y', '513', '-w', 'Kaiser', '-S', zoom_start, '-d', '0:04', '-t', zoom_title, '-o', filenames[1] ] if self.high_color: args.append('-h') if call([q_enc(a) for a in args]) != 0: raise Exception('sox returned non-zero')
def duration_text(self): return time_text(self.duration)
def duration_text(self): return time_text(sum(t.duration for t in self.tracks))