Commit 9427cf0f authored by fred's avatar fred

create-sound-waveforms: adapt to python3

parent fd797ec8
......@@ -4,6 +4,7 @@ import subprocess
import numpy as np
from django.core.management.base import BaseCommand, CommandError
from django.utils import six
from ...models import SoundFile
......@@ -52,5 +53,8 @@ class Command(BaseCommand):
'-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'))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment