- commit
- 1b78521fc4cbe7acb8cd1accd2178bfe5ba35727
- parent
- 22b97d2aac4b9a7a948d5e94e49bb936b36a8e2f
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2025-03-06 11:46
do not privilege high probability jumps
Diffstat
| M | player.py | 11 | ++++++----- |
1 files changed, 6 insertions, 5 deletions
diff --git a/player.py b/player.py
@@ -3,9 +3,9 @@ 3 3 import argparse 4 4 import gzip 5 5 import pickle -1 6 import random 6 7 import shutil 7 8 from pathlib import Path8 -1 from random import random9 9 10 10 import librosa 11 11 import numpy @@ -106,14 +106,15 @@ def enhance(jumps, threshold): 106 106 m += numpy.tri(n, k=-i).T 107 107 jumps *= (m / (n - 1)) ** 0.4 108 108 -1 109 jumps += numpy.eye(n) -1 110 109 111 return jumps 110 112 111 113 112 114 def get_next_position(i, jumps):113 -1 for j, p in sorted(enumerate(jumps[i]), key=lambda jp: -jp[1]):114 -1 if p > random():115 -1 return j + 1116 -1 return i + 1-1 115 choices, weights = zip(*enumerate(jumps[i])) -1 116 j = random.choices(choices, weights) -1 117 return j[0] + 1 117 118 118 119 119 120 def play(buffers, sample_rate, jumps):