feat: add optional Laya engine mode for grouping and language detection (#12)

Add a languageDetectionMode setting (algo | laya | laya+algo) exposed
in Settings with three engine choices. When Laya is enabled, a laya
service (Dockerfile.laya, optional compose profile, models stored
outside the repo under ./data/models/laya) can be started, with model
download and deletion from the UI via /laya routes to manage disk
space. Add a channelLanguageFusion service combining Laya results
with the existing algorithm, and wire detection mode through
grouping, channel list and player. Cover engine selection, fusion
and laya service behavior with tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
blomios
2026-10-02 11:13:34 +02:00
parent 9e80655fd9
commit ce11ecc757
19 changed files with 780 additions and 13 deletions

42
server/routes/laya.js Normal file
View File

@ -0,0 +1,42 @@
const express = require('express');
const { requireAuth, requireAdmin } = require('../auth');
const { LayaRequestError, LayaService } = require('../services/layaService');
const router = express.Router();
const laya = new LayaService();
function sendError(res, error) {
const status = error instanceof LayaRequestError ? error.statusCode : 500;
const message = error instanceof LayaRequestError ? error.message : 'Internal server error';
res.status(status).json({ runtimeAvailable: false, error: message });
}
router.get('/status', requireAuth, async (req, res) => {
res.json(await laya.status());
});
router.post('/model/download', requireAuth, requireAdmin, async (req, res) => {
try {
res.json(await laya.downloadModel(req.body?.model));
} catch (error) {
sendError(res, error);
}
});
router.delete('/model', requireAuth, requireAdmin, async (req, res) => {
try {
res.json(await laya.deleteModel());
} catch (error) {
sendError(res, error);
}
});
router.post('/language/batch', requireAuth, async (req, res) => {
try {
res.json(await laya.detectBatch(req.body));
} catch (error) {
sendError(res, error);
}
});
module.exports = router;