Archived
51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
import os
|
|
import numpy as np
|
|
from crm_options import expe_options as crmOptions
|
|
from crm_build_conditions import expe_build_conditions as buildConditions
|
|
from crm_make_stimulus import pyworld_process
|
|
|
|
|
|
def preprocess(mode, language, force):
|
|
options = {}
|
|
options["language"] = language
|
|
options["subject_name"] = ""
|
|
options = crmOptions(options)
|
|
|
|
expe, options = buildConditions(options)
|
|
|
|
options["force_rebuild_pyworld_output"] = force
|
|
|
|
print "=== Analysing all masker files ==="
|
|
|
|
for i in range(len(options["masker_corpus"])):
|
|
fname = options["masker_corpus"][i]
|
|
fname = os.path.join(options["masker_corpus_path"], fname)
|
|
print "%02d/%d Analysing '%s' \n" % (i + 1,
|
|
len(options["masker_corpus"]), fname)
|
|
for j in range(1, len(options["voices"]) + 1):
|
|
|
|
voice = options["voices"]["v" + str(j)]
|
|
pyworld_process(fname, voice["dF0"], voice["dVTL"], options)
|
|
|
|
if mode == "all":
|
|
print "=== Synthesizing for all masker files ==="
|
|
trials = expe["training"]["trials"] + expe["test"]["trials"]
|
|
|
|
k = 1
|
|
|
|
for i in range(len(trials)):
|
|
trial = trials[i]
|
|
|
|
for j in range(len(options["masker_corpus"])):
|
|
fname = options["masker_corpus"][j]
|
|
fname = os.path.join(
|
|
options["masker_corpus_path"], fname)
|
|
print "%04d/%d Synthesizing'%s' for dF0=%.2f st, dVTL=%.2f st\n" % (k, len(trials) * len(
|
|
options["masker_corpus"]), fname, trial["voice"]["dF0"], trial["voice"]["dVTL"])
|
|
pyworld_process(
|
|
fname, trial["voice"]["dF0"], trial["voice"]["dVTL"], options)
|
|
|
|
k += 1
|
|
|
|
print "\n"
|