This repository has been archived on 2026-10-21. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PICKA_python/tools/robot_calibration.py
T
2026-09-22 11:52:03 +02:00

29 lines
761 B
Python

from expe_build_conditions import expe_build_conditions
from expe_options import expe_options
import os
import soundfile as sf
import numpy as np
from naoqi import ALProxy
from tqdm import tqdm
import random
# aap = ALProxy("ALAudioPlayer", "", 9559)
options = expe_options()
expe_build_conditions(options)
files = os.listdir(options["tmp_path"] + "2")
y = np.array([])
for i in tqdm(range(len(files))):
r = random.randint(0, len(files)-1)
x, fs = sf.read(os.path.join(options["tmp_path"] + "2", str(files[r])))
x = x * np.power(10, -(options["attenuation_dB"]/20.0))
y = np.append(y, x)
sf.write("calibration.wav", np.concatenate(
(np.zeros((1024*3, 2)), np.tile(y, (2, 1)).T, np.zeros((1024*3, 2)))), fs)
# aap.ALAudioPlayer.play()