From: jweigele Date: Thu, 15 Sep 2022 19:00:40 +0000 (-0700) Subject: No more ffmpeg in ffmpegfile (lol) a little laggy, maybe? X-Git-Url: http://git.hexthepla.net/?a=commitdiff_plain;h=9de5e45751dfd0349099f87474c8d40259c8e11a;p=grahbot No more ffmpeg in ffmpegfile (lol) a little laggy, maybe? --- diff --git a/ffmpegfile.py b/ffmpegfile.py index 54c0d01..927fd48 100644 --- a/ffmpegfile.py +++ b/ffmpegfile.py @@ -33,11 +33,16 @@ class AudioChunk(object): self.samples = numpy.array([x[0] for x in struct.iter_unpack(' 0: # switch to mono if needed (channel shouldn't change from initial) - if channels == 3: - next_samples = numpy.delete(next_samples, 1, 0) + #log.debug('channels are {}'.format(channels)) + if channels == 2: + #log.debug('before deleting {}'.format(next_samples.shape)) + #log.debug(next_samples[0][:10]) + #next_samples = numpy.squeeze(next_samples.reshape(1, -1)) + # total length * 2 + rechannel = numpy.empty(next_samples[0].shape[0]*2, dtype='float32') + # first channel + rechannel[::2] = next_samples[0] + # second channel + rechannel[1::2] = next_samples[1] + next_samples = rechannel + #log.debug('after deleting {}'.format(next_samples.shape)) + #log.debug(next_samples[:10]) # for the downcast to int16 next_samples *= 32768.0 next_bytes = next_samples.astype('int16')