fix: Improve Piper TTS error handling and user messaging

- Added proper error handling for missing voice models in preview endpoint
- Return 404 with helpful message when Piper models not found
- Added user-friendly alert in frontend when preview fails
- Added prominent warning in UI when Piper is selected about manual setup
- Check for empty audio before returning to prevent decode errors

Users now get clear feedback when Piper voice models are missing
instead of cryptic 'media could not be decoded' errors.
This commit is contained in:
2025-12-09 15:00:32 +00:00
parent 134b109999
commit cdd8c0fc08
3 changed files with 48 additions and 5 deletions

View File

@@ -262,6 +262,11 @@ export default function VoiceAssignmentSection({
} catch (error) {
console.error('Preview failed:', error);
setPreviewingRole(null);
// Show user-friendly error message
if (error instanceof Error) {
alert(`Voice preview failed: ${error.message}\n\nIf using Piper TTS, make sure voice models are downloaded. See backend/PIPER_SETUP.md for instructions.`);
}
}
};
@@ -350,10 +355,19 @@ export default function VoiceAssignmentSection({
</button>
</div>
{currentEngine === 'piper' && (
<div className="mt-3 p-3 bg-blue-50 border border-blue-200 rounded-lg">
<p className="text-sm text-blue-900">
<strong>✨ Pitch Control:</strong> Piper allows you to adjust voice pitch per character (coming soon in UI)
</p>
<div className="mt-3 space-y-2">
<div className="p-3 bg-blue-50 border border-blue-200 rounded-lg">
<p className="text-sm text-blue-900">
<strong>✨ Pitch Control:</strong> Piper allows you to adjust voice pitch per character (coming soon in UI)
</p>
</div>
<div className="p-3 bg-yellow-50 border border-yellow-300 rounded-lg">
<p className="text-sm text-yellow-900">
<strong>⚠️ Setup Required:</strong> Piper voice models must be downloaded manually.
See <code className="bg-yellow-100 px-1 rounded">backend/PIPER_SETUP.md</code> for instructions.
If voices don't work, you may need to download the model files first.
</p>
</div>
</div>
)}
</div>