Files
feadulta/scripts/fea_post_io.php
T
rafa db0d0a03f8 feat: TTS multi-voz por autor (MiniMax voice cloning, gitea.feadulta.com #152)
Voz clonada por autor (Fray Marcos, Pagola, Sicre, Arregi) en vez de una
única voz genérica para todo el TTS. minimax_tts.py resuelve la voz por
post_author (AUTHOR_VOICES) y cae a Nico si no hay clon; fea_post_io.php
propaga autor/voz; tts_produce.py y sync_audio_to_prod.py (local→prod,
workaround glibc rota del servidor) usan la voz correcta en vez de forzar
Nico.

Incluye fix de trim_after_author_signature: la heurística de "firma final
del autor" confundía encabezados litúrgicos iniciales (p.ej. "CORPUS (A)")
con la firma, truncando el texto a sintetizar a un par de palabras. Ahora
solo cuenta como firma un párrafo con >200 caracteres de contenido real
por delante.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-09 21:34:20 -04:00

75 lines
2.4 KiB
PHP

<?php
/**
* IO mínimo de posts WP para el reprocesador EN.
* get <id> -> escribe /tmp/fea_es.json {title, content, status}
* update <id> <titlef> <bodyf> -> actualiza post_title/post_content desde ficheros
* Carga wp-load; portable (local docker o prod via FEA_WP_LOAD).
*/
$WP = getenv('FEA_WP_LOAD') ?: '/var/www/html/wp-load.php';
require $WP;
$action = $argv[1] ?? '';
if ($action === 'get') {
$id = (int)$argv[2];
$p = get_post($id);
if (!$p) { fwrite(STDERR, "no existe $id\n"); exit(1); }
file_put_contents('/tmp/fea_es.json', json_encode([
'id' => $id,
'title' => $p->post_title,
'content' => $p->post_content,
'status' => $p->post_status,
'author' => (int)$p->post_author,
], JSON_UNESCAPED_UNICODE));
exit(0);
}
if ($action === 'update') {
$id = (int)$argv[2];
$title = rtrim(file_get_contents($argv[3]), "\r\n");
$body = file_get_contents($argv[4]);
if (!get_post($id)) { fwrite(STDERR, "no existe $id\n"); exit(1); }
$r = wp_update_post([
'ID' => $id,
'post_title' => $title,
'post_content' => $body,
], true);
if (is_wp_error($r)) { fwrite(STDERR, "error: " . $r->get_error_message() . "\n"); exit(1); }
fwrite(STDOUT, "ok actualizado $id\n");
exit(0);
}
if ($action === 'getmeta') {
echo get_post_meta((int)$argv[2], $argv[3], true);
exit(0);
}
if ($action === 'setaudio') { // setaudio <id> <relpath> [voice_id]
$id = (int)$argv[2];
$voice = $argv[4] ?? 'NicoFeadulta2026';
update_post_meta($id, 'fea_audio_url', home_url($argv[3]));
update_post_meta($id, 'fea_audio_voice', $voice);
update_post_meta($id, 'fea_audio_done', '1');
delete_post_meta($id, 'fea_audio_error');
fwrite(STDOUT, "ok " . home_url($argv[3]) . "\n");
exit(0);
}
if ($action === 'setflag') { // setflag <id> <key> <value>
update_post_meta((int)$argv[2], $argv[3], $argv[4]);
exit(0);
}
if ($action === 'unsetaudio') { // unsetaudio <id> (rollback: despublica el audio)
$id = (int)$argv[2];
delete_post_meta($id, 'fea_audio_url');
delete_post_meta($id, 'fea_audio_voice');
delete_post_meta($id, 'fea_audio_done');
delete_post_meta($id, 'fea_audio_error');
fwrite(STDOUT, "ok despublicado $id\n");
exit(0);
}
fwrite(STDERR, "uso: get|update|getmeta|setaudio|setflag|unsetaudio\n");
exit(2);