20 lines
915 B
PHP
20 lines
915 B
PHP
<?php
|
|
// opus-arch-voice.php - Cap 7 Voice skeleton
|
|
header('Content-Type: application/json');
|
|
$action = $_POST['action'] ?? $_GET['action'] ?? 'status';
|
|
if ($action === 'status') {
|
|
echo json_encode([
|
|
'ok'=>true,
|
|
'whisper_bin_exists'=>file_exists('/opt/whisper.cpp/main'),
|
|
'xtts_dir_exists'=>is_dir('/opt/xtts'),
|
|
'endpoints'=>['transcribe','synthesize','status','get_audio']
|
|
]); exit;
|
|
}
|
|
if ($action === 'transcribe' && isset($_FILES['audio'])) {
|
|
$wh = '/opt/whisper.cpp/main';
|
|
if (!file_exists($wh)) { echo json_encode(['ok'=>false,'error'=>'whisper not compiled']); exit; }
|
|
$out = shell_exec('timeout 30 '.$wh.' -m /opt/whisper.cpp/models/ggml-base.bin -f '.escapeshellarg($_FILES['audio']['tmp_name']).' 2>&1');
|
|
echo json_encode(['ok'=>true,'text'=>$out]); exit;
|
|
}
|
|
echo json_encode(['ok'=>false,'actions'=>['status','transcribe','synthesize','get_audio']]);
|