morfeo 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/instalar.mjs CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  venvListo,
23
23
  versionPython,
24
24
  } from './entorno.mjs';
25
- import {whisperListo, instalarWhisper} from './whisper.mjs';
25
+ import {faltaParaWhisper, whisperListo, instalarWhisper} from './whisper.mjs';
26
26
 
27
27
  const ok = (m) => console.log(` ✔ ${m}`);
28
28
  const no = (m) => console.log(` ✘ ${m}`);
@@ -154,7 +154,7 @@ export async function instalar(op = {}) {
154
154
  if (process.platform === 'darwin' && spawnSync('xcode-select', ['-p'], {stdio: 'ignore'}).status !== 0) {
155
155
  no('Whisper se compila y necesita las herramientas de Apple.');
156
156
  info('Corre: xcode-select --install y cuando termine: npx morfeo instalar --whisper');
157
- } else {
157
+ } else if (await herramientasWhisper(op)) {
158
158
  await instalarWhisper();
159
159
  ok('Whisper listo');
160
160
  }
@@ -164,6 +164,22 @@ export async function instalar(op = {}) {
164
164
  console.log('\nTodo listo. Prueba: npx morfeo nuevo mi-canal && cd mi-canal && npx morfeo render');
165
165
  }
166
166
 
167
+ /** Revisa git, make y cmake antes de compilar whisper.cpp; en Mac con Homebrew ofrece instalar cmake. */
168
+ async function herramientasWhisper(op) {
169
+ let falta = faltaParaWhisper();
170
+ if (falta.length === 1 && falta[0] === 'cmake' && process.platform === 'darwin' && tiene('brew')) {
171
+ if (await preguntar('Whisper necesita cmake para compilarse. ¿Lo instalo con Homebrew?', {...op, porDefecto: true})) {
172
+ correr('brew', ['install', 'cmake']);
173
+ falta = faltaParaWhisper();
174
+ }
175
+ }
176
+ if (!falta.length) return true;
177
+ no(`Whisper se compila y falta: ${falta.join(', ')}.`);
178
+ if (process.platform === 'darwin') info(`Corre: brew install ${falta.join(' ')} y cuando termine: npx morfeo instalar --whisper`);
179
+ else info(`Instálalo con tu gestor de paquetes (por ejemplo: sudo apt install ${falta.join(' ')} ) y luego: npx morfeo instalar --whisper`);
180
+ return false;
181
+ }
182
+
167
183
  /** Devuelve el estado de cada pieza; con imprimir=true lo muestra. */
168
184
  export async function doctor({imprimir = true} = {}) {
169
185
  const estado = [];
package/lib/whisper.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  // Whisper (opcional): tiempos reales de cada palabra para los subtítulos.
2
2
  import {downloadWhisperModel, installWhisperCpp, toCaptions, transcribe} from '@remotion/install-whisper-cpp';
3
- import {execFileSync} from 'node:child_process';
3
+ import {execFileSync, spawnSync} from 'node:child_process';
4
4
  import fs from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import {WHISPER, pythonVenv} from './entorno.mjs';
@@ -10,8 +10,24 @@ export const MODELO_WHISPER = 'small';
10
10
 
11
11
  export const whisperListo = () => fs.existsSync(path.join(WHISPER, `ggml-${MODELO_WHISPER}.bin`)) && fs.existsSync(path.join(WHISPER, '.listo'));
12
12
 
13
+ /** Herramientas que whisper.cpp necesita para compilarse (en Windows se descarga ya compilado). */
14
+ export function faltaParaWhisper() {
15
+ if (process.platform === 'win32') return [];
16
+ return ['git', 'make', 'cmake'].filter((cmd) => spawnSync('which', [cmd], {stdio: 'ignore'}).status !== 0);
17
+ }
18
+
19
+ // Mismo lugar donde Remotion busca el ejecutable desde whisper.cpp 1.7.4.
20
+ const compilado = () => fs.existsSync(path.join(WHISPER, 'build', 'bin', process.platform === 'win32' ? 'whisper-cli.exe' : 'whisper-cli'));
21
+
13
22
  export async function instalarWhisper() {
14
- await installWhisperCpp({to: WHISPER, version: VERSION_CPP, printOutput: true});
23
+ // Un intento anterior que falló a medias deja la carpeta sin el ejecutable, y Remotion se niega a seguir: se limpia.
24
+ if (fs.existsSync(WHISPER) && !compilado()) fs.rmSync(WHISPER, {recursive: true, force: true});
25
+ try {
26
+ await installWhisperCpp({to: WHISPER, version: VERSION_CPP, printOutput: true});
27
+ } catch (e) {
28
+ if (!compilado()) fs.rmSync(WHISPER, {recursive: true, force: true});
29
+ throw e;
30
+ }
15
31
  await downloadWhisperModel({model: MODELO_WHISPER, folder: WHISPER, printOutput: true});
16
32
  fs.writeFileSync(path.join(WHISPER, '.listo'), VERSION_CPP);
17
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "morfeo",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Genera videos verticales animados (Remotion + Three.js) con voz, música y subtítulos, desde un guion en código o escrito por IA.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",