diff --git a/backend/lib/transcriptor.js b/backend/lib/transcriptor.js index 6066ec4..a3dcdf0 100644 --- a/backend/lib/transcriptor.js +++ b/backend/lib/transcriptor.js @@ -38,7 +38,11 @@ export async function transcribir(audioUrl, idioma = 'es') { // En Vercel Serverless (Node < 20), Web API `File` no está disponible por defecto, // y `arrayBuffer` consume mucha RAM. `toFile` soluciona ambos. - const audioFile = toFile(audioResponse, 'audio.mp3', { type: 'audio/mpeg' }) + // Detectar extensión real del audio (TikTok→mp3, Instagram→m4a, etc.) + const ext = audioUrl.split('?')[0].split('.').pop()?.toLowerCase() || 'mp3' + const mimeMap = { mp3: 'audio/mpeg', m4a: 'audio/mp4', mp4: 'audio/mp4', webm: 'audio/webm', ogg: 'audio/ogg', wav: 'audio/wav' } + const mimeType = mimeMap[ext] || 'audio/mpeg' + const audioFile = toFile(audioResponse, `audio.${ext}`, { type: mimeType }) const transcripcion = await openai.audio.transcriptions.create({ file: audioFile, diff --git a/vercel.json b/vercel.json index c3dbe51..7614ef8 100644 --- a/vercel.json +++ b/vercel.json @@ -2,8 +2,7 @@ "buildCommand": "cd frontend && npm install && npm run build", "outputDirectory": "frontend/dist", "functions": { - "api/analizar.js": { "maxDuration": 300 }, - "api/generar.js": { "maxDuration": 120 } + "api/**/*.js": { "maxDuration": 60 } }, "rewrites": [ { "source": "/api/(.*)", "destination": "/api/$1" },