gpt-4o-2024-08-06· OpenAI
WildChat-4.8M (AI2)
function autRevisarAudio($audio) { // Verificar si el archivo existe if…
- User
function autRevisarAudio(audio) { // Verificar si el archivo existe if (!file_exists(audio)) { error_log("El archivo de audio no existe: " . $audio); return; }
code// 1. Verificar si el audio ya está publicado en WordPress $existing_attachment = attachment_url_to_postid(wp_get_attachment_url_by_path($audio)); if ($existing_attachment) { return; } // 2. Generar un hash del archivo de audio $file_hash = hash_file('sha256', $audio); if (!$file_hash) { error_log("Error al generar el hash para el archivo: " . $audio); return; } // 3. Comprobar si el hash ya existe en la base de datos $hash_exists = obtenerHash($file_hash); if ($hash_exists) { return; } // 4. Si el hash no existe, guardar el hash y enviar el archivo para procesamiento // Obtener la URL del archivo de audio $upload_dir = wp_upload_dir(); $file_url = str_replace($upload_dir['basedir'], $upload_dir['baseurl'], $audio); aqui necesito que el user id siempre sea 44 $user_id = get_current_user_id(); if (!$user_id) { // Si no hay un usuario autenticado, puedes asignar un ID de usuario por defecto $user_id = 0; // O maneja este caso según tus necesidades } // Guardar el hash en la base de datos con estado 'pending' $hash_id = guardarHash($file_hash, $file_url, 'pending', $user_id); if (!$hash_id) { error_log("Error al guardar el hash en la base de datos para el archivo: " . $audio); return; } aqui esto se esta trabajando directamente en function php // 5. Incluir o llamar a autLiteAudio.php para procesar el audio // Asegúrate de que la ruta a autLiteAudio.php sea correcta $autLiteAudioPath = plugin_dir_path(__FILE__) . 'autLiteAudio.php'; if (file_exists($autLiteAudioPath)) { // Puedes pasar el hash_id o la ruta del archivo según cómo esté diseñada autLiteAudio.php include_once $autLiteAudioPath; if (function_exists('procesarAudio')) { procesarAudio($audio, $hash_id); } else { error_log("La función procesarAudio no existe en autLiteAudio.php"); } } else { error_log("No se encontró autLiteAudio.php en la ruta: " . $autLiteAudioPath); } - Assistant