Skip to content

Instantly share code, notes, and snippets.

@kkoch986
Last active June 9, 2023 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kkoch986/92f67be323e5a2349bf5acebdcc828ef to your computer and use it in GitHub Desktop.
Save kkoch986/92f67be323e5a2349bf5acebdcc828ef to your computer and use it in GitHub Desktop.
wip chataigne module for loading phonemes into a sequence
function cmdGenerate() {
// the source file with the timestamped phonemes to read from
// TODO: take the input as an audio target
var inputFile = local.parameters.inputFile.getAbsolutePath();
// the target for writing the keyframes
// TODO: create a new mapping layer instead of requiring one as input
var automation = local.parameters.outputMapping.getTarget().getParent();
// a map of viseme name to 0 - 1 values, can be editedby tweaking the optons in chataigne
var visemeList = local.parameters.visemeLevels.getTarget().getAllOptions();
var visemeMap = {};
for (i = 0 ; i < visemeList.length ; i++) {
visemeMap[visemeList[i].key] = visemeList[i].value;
}
var data = util.readFile(inputFile).split("\n");
for (i = 0 ; i < data.length ; i++) {
var parts = data[i].split(" ");
if (!parts[0]) {
continue ;
}
var value = visemeMap[parts[1]];
if (!value) {
value = 0;
}
// script.log(parts[0] + " -> " + parts[1] + " ( " + value + " )");
automation.addKeys(parts[0], value);
}
// TODO add a 0 at the end of the audio clip
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment