import numpy as np
from django.core.management.base import BaseCommand, CommandError
+from django.utils import six
from ...models import SoundFile
'-e' 'unsigned-integer', '-b', '8', '-']
wave_array = subprocess.check_output(cmd)
# reduce to 200 samples of max positive value
- wave_reduced = [max(x) for x in np.array_split(np.array([max(0, ord(x)-128) for x in wave_array]), 200)]
- json.dump(wave_reduced, file(file_path, 'w'))
+ if six.PY3:
+ wave_reduced = [int(max(x)) for x in np.array_split(np.array([max(0, x-128) for x in wave_array]), 200)]
+ else:
+ wave_reduced = [max(x) for x in np.array_split(np.array([max(0, ord(x)-128) for x in wave_array]), 200)]
+ json.dump(wave_reduced, open(file_path, 'w'))