OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
whisper
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
06/17/2025 10:17:24 AM
rwxrwxr-x
📄
index.php
3.98 KB
05/19/2025 10:07:13 AM
rw-r--r--
📄
transcribe.php
2.17 KB
05/19/2025 10:07:13 AM
rw-r--r--
📁
uploads
-
04/23/2025 08:57:45 AM
rwxr-xr-x
📄
whisper_log.txt
29.34 KB
04/23/2025 08:57:43 AM
rw-r--r--
Editing: transcribe.php
Close
<?php $uploadDir = __DIR__ . DIRECTORY_SEPARATOR . 'uploads' . DIRECTORY_SEPARATOR; if (!file_exists($uploadDir)) { mkdir($uploadDir, 0755, true); } function logError($message) { file_put_contents(__DIR__ . DIRECTORY_SEPARATOR . 'whisper_log.txt', date('[Y-m-d H:i:s] ') . $message . PHP_EOL, FILE_APPEND); } if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['audio'])) { if ($_FILES['audio']['error'] !== UPLOAD_ERR_OK) { logError("Upload error: " . $_FILES['audio']['error']); echo json_encode(['error' => 'File upload failed', 'text' => '']); exit; } $timestamp = time(); $webmFile = 'audio_' . $timestamp . '.webm'; $webmPath = $uploadDir . $webmFile; if (!move_uploaded_file($_FILES['audio']['tmp_name'], $webmPath)) { logError("Failed to move uploaded file"); echo json_encode(['error' => 'Failed to save audio', 'text' => '']); exit; } $currentDir = getcwd(); chdir($uploadDir); // ✅ DO NOT wrap in extra quotes manually $whisperPath = 'C:\\Python312\\Scripts\\whisper.exe'; $whisperCmd = 'cmd /c ' . escapeshellarg($whisperPath) . ' ' . escapeshellarg($webmFile) . ' --model base --language English --output_format txt 2>&1'; logError("Whisper command: $whisperCmd"); exec($whisperCmd, $whisperOutput, $whisperReturnVal); logError("Whisper output: " . print_r($whisperOutput, true)); logError("Whisper return: $whisperReturnVal"); chdir($currentDir); if ($whisperReturnVal !== 0) { echo json_encode(['error' => 'Transcription failed', 'text' => '']); exit; } $txtPath = $uploadDir . pathinfo($webmFile, PATHINFO_FILENAME) . '.txt'; if (file_exists($txtPath)) { $transcription = file_get_contents($txtPath); echo json_encode(['text' => $transcription]); } else { logError("Transcription file not found: " . $txtPath); echo json_encode(['error' => 'Transcription file not found', 'text' => '']); } } else { echo json_encode(['error' => 'No audio file received', 'text' => '']); } ?>