neuro-team-femto / cleese

Combinatorial Expressive Speech Engine
MIT License
42 stars 10 forks source link

Error in the parsing of config file #32

Open Pablo-Arias opened 2 months ago

Pablo-Arias commented 2 months ago

Hi there,

I'm trying to run the cleese example shown in the tutorial—the one that transform the pitch of "really". I'm using the code provided in the tutorial. As well as the same configuration file used in the tutorial. Code is below. It seems that there is a problem in that configuration file, because the config file is missing a "main" element. I feel it's about the way the config file is being parssed, which tries to access "main" but in the tutorial only "pitch" is specified?

Thank you! Pablo

Error:

  File "/Users/arias/Desktop/Projects/multimodal_rev_corr/stimulus_generation/cleese/generate_sounds.py", line 17, in <module>
    wave_out,bpf_out = cleese.process_data(PhaseVocoder, wave_in, config_file, sample_rate=sr)
  File "/Users/arias/opt/anaconda3/envs/cleese/lib/python3.8/site-packages/cleese_stim/cleese.py", line 28, in process_data
    return engine.process(data, conf, **kwargs)
  File "/Users/arias/opt/anaconda3/envs/cleese/lib/python3.8/site-packages/cleese_stim/engines/phase_vocoder/phase_vocoder.py", line 79, in process
    config["main"]['inSamples'] = len(waveIn)
KeyError: 'main'

My code:

import numpy as np
import matplotlib.pyplot as plt
import cleese_stim as cleese
from cleese_stim.engines import PhaseVocoder

import os
input_file = os.path.abspath("original_sound/female.wav")
config_file = os.path.abspath("random_pitch_profile.toml")

# read input wavefile
wave_in, sr, _ = PhaseVocoder.wav_read(input_file)

# transform sound
wave_out,bpf_out = cleese.process_data(PhaseVocoder, wave_in, config_file, sample_rate=sr)

# save file if necessary
output_file = "transformed/1.wav"
PhaseVocoder.wav_write(wave_out, output_file, sr)

Configuration file:


[pitch]
# pitch transposition window in seconds. If 0 : static transformation
window.len = 0.11

# number of pitch transposition windows. If 0 : static transformation
window.count = 6

# 's': force winlength in seconds,'n': force number of windows (equal length)
window.unit = 'n'

# standard deviation (cents) for random transposisiton (Gaussian distrib for now)
std = 300

# truncate distribution values (factor of std)
trunc = 1

# type of breakpoint function:
#      'ramp': linear interpolation between breakpoints
#      'square': square BPF, with specified transition times at edges
BPFtype = 'ramp'

# in s: transition time for square BPF
trTime = 0.02