mirror of
https://github.com/hanzoai/chat.git
synced 2026-09-30 20:51:17 +00:00
librechat-data-provider → @hanzochat/data-provider @librechat/data-schemas → @hanzochat/data-schemas @librechat/client → @hanzochat/client (@hanzochat/api already forked; external @librechat/agents fork follows) All imports, package.json names/deps, tsconfig path aliases, jest moduleNameMapper, and rollup/vite build aliases updated. The data-provider react-query subpath resolves via the exports map. Lockfiles regenerated in a follow-on once the canonical package manager is confirmed.
43 lines
1.4 KiB
JavaScript
43 lines
1.4 KiB
JavaScript
const multer = require('multer');
|
|
const express = require('express');
|
|
const { logger } = require('@hanzochat/data-schemas');
|
|
const { CacheKeys } = require('@hanzochat/data-provider');
|
|
const { getVoices, streamAudio, textToSpeech } = require('~/server/services/Files/Audio');
|
|
const { getLogStores } = require('~/cache');
|
|
|
|
const router = express.Router();
|
|
const upload = multer();
|
|
|
|
router.post('/manual', upload.none(), async (req, res) => {
|
|
await textToSpeech(req, res);
|
|
});
|
|
|
|
const logDebugMessage = (req, message) =>
|
|
logger.debug(`[streamAudio] user: ${req?.user?.id ?? 'UNDEFINED_USER'} | ${message}`);
|
|
|
|
// TODO: test caching
|
|
router.post('/', async (req, res) => {
|
|
try {
|
|
const audioRunsCache = getLogStores(CacheKeys.AUDIO_RUNS);
|
|
const audioRun = await audioRunsCache.get(req.body.runId);
|
|
logDebugMessage(req, 'start stream audio');
|
|
if (audioRun) {
|
|
logDebugMessage(req, 'stream audio already running');
|
|
return res.status(401).json({ error: 'Audio stream already running' });
|
|
}
|
|
audioRunsCache.set(req.body.runId, true);
|
|
await streamAudio(req, res);
|
|
logDebugMessage(req, 'end stream audio');
|
|
res.status(200).end();
|
|
} catch (error) {
|
|
logger.error(`[streamAudio] user: ${req.user.id} | Failed to stream audio: ${error}`);
|
|
res.status(500).json({ error: 'Failed to stream audio' });
|
|
}
|
|
});
|
|
|
|
router.get('/voices', async (req, res) => {
|
|
await getVoices(req, res);
|
|
});
|
|
|
|
module.exports = router;
|