odant-work 1.0.57 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/#system/package-manifest.json +11 -11
- package/MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js +23 -2
- package/package.json +1 -1
- package/sources/data/progress.md +3 -0
- package/sources/modules/agent/voice.js +3 -0
- package/sources/modules/trainer/huggingface.js +25 -0
- package/sources/modules/trainer/index.js +9 -3
- package/sources/modules/trainer/local-engine.js +14 -0
- package/sources/modules/trainer/worker/local_infer_worker.py +128 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"packageName": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.58",
|
|
4
4
|
"createdAt": 1795100682741,
|
|
5
|
-
"updatedAt":
|
|
5
|
+
"updatedAt": 1795159570410,
|
|
6
6
|
"files": {
|
|
7
7
|
"run.mjs": "f8918c612e8641e9beee06221be6680aa6fd21f25468451f2ac857fd51772266",
|
|
8
|
-
"package.json": "
|
|
9
|
-
"package-lock.json": "
|
|
8
|
+
"package.json": "8d3d1fd35f236297d0cd4af83dcaa794c852aa2c80000fe58a013d2ce20ea9f0",
|
|
9
|
+
"package-lock.json": "b8b0d594742d002b05c0ffeed9e831dbdc44c6c7e0b8e69797c564723c42034b",
|
|
10
10
|
"sources/client/class.js": "c3fb8f143fc83aaa2df1ddeddd412d2d4dfe88656578095babe2df34fb3b3922",
|
|
11
11
|
"sources/client/field.js": "ffdd50fa8b6ec515cc42da5fca96658ff2b20e274601a1f926e0031372467a19",
|
|
12
12
|
"sources/client/file.js": "667101d75fa30840370d5be232e518aaac7c1fd52ca05a12da560eef6c0848b0",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"sources/data/objects.js": "23f51d5b00cd766fe27879b874738bc9bd9056bd6e27285fb7a52926c0dbc6a8",
|
|
27
27
|
"sources/data/posting.js": "6595bb9ec632539ae7629504db327d25a491e61c1cdc598bb43d08ea0d45548d",
|
|
28
28
|
"sources/data/print.js": "48545bf8f35a6f3188b424aa9c3180508b272e0441375461fc361d4bcd565faf",
|
|
29
|
-
"sources/data/progress.md": "
|
|
29
|
+
"sources/data/progress.md": "53cf1c2c23aa876c28a63159cedd86d9b124cb92af5312fab11a6c0757dc5fc3",
|
|
30
30
|
"sources/data/readme.md": "593fa2ae07aa91bc26d7542275da6953a9cd419240a9a49e00cb62fb9d5d8e36",
|
|
31
31
|
"sources/data/reports.js": "0330f404860fe2589a7d46a2f0fe690ca23249bd841a062a26718742d4fd11d6",
|
|
32
32
|
"sources/data/schema.js": "311b03b75f0aab3bad16d3b389ba08588b68599cc297a671120b7c3e71670d14",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
"sources/modules/agent/types.d.ts": "9d47168bb9fefb1d7c5506afb263c6a6f2e3609602ee78e50c98c02bc052831f",
|
|
112
112
|
"sources/modules/agent/undo.js": "e46f3f1172c6d6e4055332bada74c546c0b0a0e585f1c96eac9b40e4d35b8544",
|
|
113
113
|
"sources/modules/agent/util.js": "9bca6569c16cdfed0134dfec0c99347b3e999692afdc35719886f6083fed87c5",
|
|
114
|
-
"sources/modules/agent/voice.js": "
|
|
114
|
+
"sources/modules/agent/voice.js": "f4f8195a7d1745f4f26d85c3efeea7adb53288b72ceb557aae3b3b72a107dd27",
|
|
115
115
|
"sources/modules/ai-schema.js": "84ecc7a872dec42e521f9e05366f053e36ae19b185f35c552b945157f95c66f4",
|
|
116
116
|
"sources/modules/bridge/chrome.js": "3bbba8c1726ef8341918bf94d9542093d47e57ec5364f600e863fe2500342e37",
|
|
117
117
|
"sources/modules/bridge/hub.js": "4398d503ad2581fad763ec2f56a6893cd00ecc6f0c0af42523f77de43c4e5f45",
|
|
@@ -177,15 +177,15 @@
|
|
|
177
177
|
"sources/modules/trainer/dataset.js": "e631e1feda2958cf93436cb48a331958d7b029aa52bd42247865e87504b642f7",
|
|
178
178
|
"sources/modules/trainer/downloader.js": "d9e96cb07e7bf64386558be8c2265c482af35a513f42954250add6d5fc87bdc4",
|
|
179
179
|
"sources/modules/trainer/halogen.js": "bd08cb4a5475e6b6f0d13fdf3458f2b3ef49e1997eb275c85dfd0ca9e6848457",
|
|
180
|
-
"sources/modules/trainer/huggingface.js": "
|
|
181
|
-
"sources/modules/trainer/index.js": "
|
|
182
|
-
"sources/modules/trainer/local-engine.js": "
|
|
180
|
+
"sources/modules/trainer/huggingface.js": "6fdd1e50e771ffbf7e9374c8170594d69dfb19642e10eeaf9d03edc99b555031",
|
|
181
|
+
"sources/modules/trainer/index.js": "b3089564fba397e3d11dbd9758d3d3ceff6abadd376e279895db3f01b538eabc",
|
|
182
|
+
"sources/modules/trainer/local-engine.js": "5eeb8e1fd02f792f0bcb5996e311fcdc0fd0599bfb3bae4ab875d930d94b584a",
|
|
183
183
|
"sources/modules/trainer/paths.js": "4d3e2503889ef2cdb6feb5979576ac2b289974cdb407a40e1bef797ce421e45c",
|
|
184
184
|
"sources/modules/trainer/providers.js": "190ca237108ee386fd7f27c66ea4be60411b2823b1c027fc6e44dfdcb419ec86",
|
|
185
185
|
"sources/modules/trainer/runner.js": "328843672fe0c1bd7e8c35c2e25285c31a9f749e04814e64c32e8cae74086024",
|
|
186
186
|
"sources/modules/trainer/tar-stream.js": "52f1739579a01818b53d04a93fd05a91c49a0716019f309a6fca951ba112794f",
|
|
187
187
|
"sources/modules/trainer/transfer.js": "2c603d538e0f85e1794e2f304081fac136f0ff72f85d8b00c2141c7402b3a1fb",
|
|
188
|
-
"sources/modules/trainer/worker/local_infer_worker.py": "
|
|
188
|
+
"sources/modules/trainer/worker/local_infer_worker.py": "ec1e0a5e3f8ee3c3df96291f2746162a514ddbb26381589aab6daa1c7997807a",
|
|
189
189
|
"sources/modules/trainer/worker/unsloth_train.py": "7774d94ffa6f60eed20c57a8dfdc12621d5d9f74d594c605dff32ff70e321e33",
|
|
190
190
|
"sources/modules/user-profile/user-profile.js": "5c8fd002809848b204aee83a44161375e8144bffcc048fde748f4f778162bbef",
|
|
191
191
|
"sources/modules/user-profile/user-token.js": "3797685232684e9e80261a2e63f70cbff4ef1bcc3ded6f755800804e9848d7d9",
|
|
@@ -981,7 +981,7 @@
|
|
|
981
981
|
"MODULES/Register/STRUCTS/Паспорт/$struct/class.js": "4a50808e4db7741b0384a775177545d71686a680ccda7ef0ec68bf81f9c988b5",
|
|
982
982
|
"MODELS/$ai/$folder/$class/$ai/class.js": "766a73b4e110df0643edb2609e4bf46250e21c636ae6e86417147b234aa87c30",
|
|
983
983
|
"MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/class.js": "fe5ba834156495c28a34acd4b70a6b6b3bdfccb67ec7bf99e92a292afbb66d19",
|
|
984
|
-
"MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js": "
|
|
984
|
+
"MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js": "a73d70c0be957ca372e4acb58664efba135d2313243d67030d5b79d5db512be4",
|
|
985
985
|
"MODELS/$ai/$folder/$class/$ai/methods/chat/$method/class.js": "02fbb40d8ce93fbf568a6a8036c199e2af815be3d63d81f815aeb1da999db717",
|
|
986
986
|
"MODELS/$ai/$folder/$class/$provider/class.js": "069073501b93a95bb9d77e59ce71e53c7a8bcab2564c391b551f68a2453ac486",
|
|
987
987
|
"MODELS/$ai/$folder/$class/$provider/handlers/pages/form/provider/$handler/class.js": "8d327820cefd696d351ac4fa7998994039e4d57ef7a9f8ae297209e4dd1b0a9e",
|
|
@@ -292,6 +292,14 @@ export default {
|
|
|
292
292
|
{{$for.item.label}}
|
|
293
293
|
</button>
|
|
294
294
|
</div>
|
|
295
|
+
<div class="chips" style="gap:6px;" ~if="ttsKind === 'silero'">
|
|
296
|
+
<button type="button" class="btn" ~for="sileroVoicePresets"
|
|
297
|
+
:style="testSileroVoice === $for.item.speaker ? 'border-color:var(--accent-color,#4f46e5);color:var(--accent-color,#4f46e5);' : ''"
|
|
298
|
+
@tap="testSileroVoice = $for.item.speaker">
|
|
299
|
+
{{$for.item.label}}
|
|
300
|
+
</button>
|
|
301
|
+
</div>
|
|
302
|
+
<div ~if="ttsKind === 'silero'" style="font-size:12px;opacity:0.8;">Silero v5.6 RU поддерживает автоударения, омографы, вопросы и ручную пометку ударения знаком <code>+</code> перед гласной (например: «зам+ок», «г+отов»).</div>
|
|
295
303
|
<div class="chips" style="gap:6px;" ~if="ttsKind === 'kokoro'">
|
|
296
304
|
<button type="button" class="btn" ~for="kokoroVoicePresets"
|
|
297
305
|
:style="testKokoroVoice === $for.item.speaker ? 'border-color:var(--accent-color,#4f46e5);color:var(--accent-color,#4f46e5);' : ''"
|
|
@@ -299,8 +307,8 @@ export default {
|
|
|
299
307
|
{{$for.item.label}}
|
|
300
308
|
</button>
|
|
301
309
|
</div>
|
|
302
|
-
<div ~if="ttsKind === 'kokoro'" style="font-size:12px;opacity:0.8;">Kokoro-82M работает с EN/FR/ES/IT/PT/JA/ZH (для русского языка используйте Piper TTS RU или Qwen3-TTS).</div>
|
|
303
|
-
<div class="chips" style="gap:6px;" ~if="ttsKind !== 'base' && ttsKind !== 'piper' && ttsKind !== 'kokoro'">
|
|
310
|
+
<div ~if="ttsKind === 'kokoro'" style="font-size:12px;opacity:0.8;">Kokoro-82M работает с EN/FR/ES/IT/PT/JA/ZH (для русского языка используйте Silero TTS RU, Piper TTS RU или Qwen3-TTS).</div>
|
|
311
|
+
<div class="chips" style="gap:6px;" ~if="ttsKind !== 'base' && ttsKind !== 'piper' && ttsKind !== 'kokoro' && ttsKind !== 'silero'">
|
|
304
312
|
<button type="button" class="btn" ~for="ttsVoicePresets"
|
|
305
313
|
:style="(isCustomVoice06B ? testTtsVoice === $for.item.speaker : testTtsInstructions === $for.item.value) ? 'border-color:var(--accent-color,#4f46e5);color:var(--accent-color,#4f46e5);' : ''"
|
|
306
314
|
@tap="selectTtsPreset($for.item)">
|
|
@@ -386,6 +394,14 @@ export default {
|
|
|
386
394
|
{ label: 'Мужской (Дмитрий)', speaker: 'dmitri' },
|
|
387
395
|
{ label: 'Женский (Ирина)', speaker: 'irina' },
|
|
388
396
|
],
|
|
397
|
+
testSileroVoice: 'xenia',
|
|
398
|
+
sileroVoicePresets: [
|
|
399
|
+
{ label: 'Женский (Ксения · xenia)', speaker: 'xenia' },
|
|
400
|
+
{ label: 'Женский мягкий (Бая · baya)', speaker: 'baya' },
|
|
401
|
+
{ label: 'Женский чёткий (Ксения · kseniya)', speaker: 'kseniya' },
|
|
402
|
+
{ label: 'Мужской (Айдар · aidar)', speaker: 'aidar' },
|
|
403
|
+
{ label: 'Мужской (Евгений · eugene)', speaker: 'eugene' },
|
|
404
|
+
],
|
|
389
405
|
testKokoroVoice: 'af_heart',
|
|
390
406
|
kokoroVoicePresets: [
|
|
391
407
|
{ label: 'EN Женский (Heart)', speaker: 'af_heart' },
|
|
@@ -450,6 +466,8 @@ export default {
|
|
|
450
466
|
const hay = `${id} ${task}`;
|
|
451
467
|
if (hay.includes('piper'))
|
|
452
468
|
return 'piper';
|
|
469
|
+
if (hay.includes('silero'))
|
|
470
|
+
return 'silero';
|
|
453
471
|
if (hay.includes('kokoro'))
|
|
454
472
|
return 'kokoro';
|
|
455
473
|
if (hay.includes('voicedesign') || hay.includes('voice_design'))
|
|
@@ -726,6 +744,9 @@ export default {
|
|
|
726
744
|
if (this.ttsKind === 'piper') {
|
|
727
745
|
body.voice = this.testPiperVoice || 'dmitri';
|
|
728
746
|
}
|
|
747
|
+
else if (this.ttsKind === 'silero') {
|
|
748
|
+
body.voice = this.testSileroVoice || 'xenia';
|
|
749
|
+
}
|
|
729
750
|
else if (this.ttsKind === 'kokoro') {
|
|
730
751
|
body.voice = this.testKokoroVoice || 'af_heart';
|
|
731
752
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "odant-work",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.58",
|
|
4
4
|
"description": "ODANT-WORK — платформа цифровой организации (встроенная система учёта, документооборот, управление процессами и приватный мультимодальный ИИ)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "sources/work.js",
|
package/sources/data/progress.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Прогресс: sources/data
|
|
2
2
|
|
|
3
3
|
## Последние изменения
|
|
4
|
+
- [~10:30, 20.11] Поддержка локального русского синтеза речи **`Silero TTS v5.6 RU`** (`snakers4/silero-models` -> `/MODELS/Local/Silero-TTS-RU`) (`sources/modules/trainer/{huggingface,local-engine,index}.js`, `sources/modules/trainer/worker/local_infer_worker.py`, `sources/modules/agent/voice.js`, `MODELS/$ai/$folder/$class/$ai/handlers/pages/form/trainer/$handler/trainer.js`, `tests/halogen-speculation.test.js`):
|
|
5
|
+
- **Быстрая установка и 100% оффлайн-инференс (`v5_6_ru.pt`, ~141 МБ):** в каталог `/MODELS/Local` добавлена курируемая карточка `Silero TTS v5.6 RU` (`customFiles` с официального `models.silero.ai`), `packagesForModality` требует только `torch`, а `_find_silero_tts_file` / `_handle_tts_silero` загружают модель через `torch.package.PackageImporter` на CPU (`48 кГц`, автоударения, омографы, вопросы, разбиение длинного текста на чанки).
|
|
6
|
+
- **Выбор 5 русских дикторов и приоритет в голосовом агенте:** в карточке `$ai` добавлены кнопки пресетов (`xenia`, `baya`, `kseniya`, `aidar`, `eugene`) и подсказка про ударения `+`, а в `sources/modules/agent/voice.js` `Silero` получила приоритет для русской озвучки.
|
|
4
7
|
- [~17:15, 19.11] Поддержка `Kokoro-82M` (`kokoro`), исправление классификации `LTX-2.5-GGUF` и честная диагностика single-file / ComfyUI моделей (`FLUX.2-klein-4b-fp8`, `LTX-2.5-GGUF`) (`sources/modules/trainer/{paths,huggingface,providers,halogen,local-engine,index}.js`, `sources/modules/trainer/worker/local_infer_worker.py`, `sources/modules/agent/voice.js`, `MODELS/$ai/$folder/$class/{$ai,$provider}/handlers/pages/form/trainer/$handler/trainer.js`, `tests/halogen-speculation.test.js`):
|
|
5
8
|
- **Поддержка `hexgrad/Kokoro-82M` (`_find_kokoro_files`, `_handle_tts_kokoro`):** `local_infer_worker.py` и `local-engine.js` распознают `kokoro-v1_0.pth` + `config.json` + `voices/*.pt`, автоматически подтягивают Python-пакет `kokoro` + `soundfile` вместо `qwen-tts` и озвучивают локально без обращений к сети; в карточке `$ai` добавлены пресеты голосов (`af_heart`, `af_bella`, `am_adam`, `am_michael`, `bf_emma`, `bm_george`) и английская тестовая фраза по умолчанию.
|
|
6
9
|
- **Классификация `LTX-2.5-GGUF` и изоляция `bubo.exe` (`huggingface.js`, `halogen.js`, `index.js`, `local-engine.js`):** `inferModalityAndCapabilities` распознаёт `ltx-2` / `ltx-2.5` / `ltxv` как `video`, `registerLocalModelNode` не назначает `protocol: 'openai'` видео/аудио/image-моделям в `.gguf`, `trainer_model_info` автоматически исправляет ранее сохранённые карточки (`modality: 'video'`, `protocol: 'local'`, `icon: 'av:videocam'`), а `findLocalGgufModel` и `localStreamChat` больше не передают диффузионные `.gguf` в `bubo.exe`.
|
|
@@ -52,6 +52,9 @@ async function localVoiceModel(cap) {
|
|
|
52
52
|
if (!matches.length)
|
|
53
53
|
return null;
|
|
54
54
|
if (cap === 'tts' && matches.length > 1) {
|
|
55
|
+
const silero = matches.find(m => /silero/i.test(String(m.id || m.model || m.path || '')));
|
|
56
|
+
if (silero)
|
|
57
|
+
return silero;
|
|
55
58
|
const piper = matches.find(m => /piper/i.test(String(m.id || m.model || m.path || '')));
|
|
56
59
|
if (piper)
|
|
57
60
|
return piper;
|
|
@@ -425,6 +425,31 @@ export const CURATED_HF_MODELS = Object.freeze([
|
|
|
425
425
|
downloads: 920000,
|
|
426
426
|
likes: 2150,
|
|
427
427
|
},
|
|
428
|
+
{
|
|
429
|
+
id: 'snakers4/silero-models',
|
|
430
|
+
folderName: 'Silero-TTS-RU',
|
|
431
|
+
author: 'Silero',
|
|
432
|
+
modelName: 'Silero TTS v5.6 RU (Чистый русский голос: 5 дикторов, CPU)',
|
|
433
|
+
modality: 'audio',
|
|
434
|
+
format: 'pytorch',
|
|
435
|
+
paramsB: 0.06,
|
|
436
|
+
ramRequiredGb: 0.35,
|
|
437
|
+
trainRamGb: 0.6,
|
|
438
|
+
capabilities: ['tts', 'voice'],
|
|
439
|
+
customFiles: [
|
|
440
|
+
{
|
|
441
|
+
name: 'v5_6_ru.pt',
|
|
442
|
+
destRelPath: 'v5_6_ru.pt',
|
|
443
|
+
url: 'https://models.silero.ai/models/tts/ru/v5_6_ru.pt',
|
|
444
|
+
size: 147664410,
|
|
445
|
+
},
|
|
446
|
+
],
|
|
447
|
+
whatItDoes: 'Чистейшая русская речь с автоударениями, омографами и вопросами за 0.1–0.3 с на CPU (5 дикторов: Айдар, Бая, Ксения, Женя, Евгений)',
|
|
448
|
+
recommendedFor: 'Лучшее качество русского произношения и ударений (~141 МБ, работает на любом ПК без GPU)',
|
|
449
|
+
tags: ['audio', 'tts', 'text-to-speech', 'voice', 'silero', 'russian'],
|
|
450
|
+
downloads: 1200000,
|
|
451
|
+
likes: 3400,
|
|
452
|
+
},
|
|
428
453
|
{
|
|
429
454
|
id: 'hexgrad/Kokoro-82M',
|
|
430
455
|
author: 'hexgrad',
|
|
@@ -439,7 +439,9 @@ async function runSingleModelSmokeTest(ai, p = {}) {
|
|
|
439
439
|
const t0 = Date.now();
|
|
440
440
|
try {
|
|
441
441
|
if (modality === 'tts') {
|
|
442
|
-
const
|
|
442
|
+
const hay = `${ai?.id || ''} ${ai?.model || ''} ${ai?.DATA?.hfRepo || ''}`.toLowerCase();
|
|
443
|
+
const isKokoro = hay.includes('kokoro');
|
|
444
|
+
const isSilero = hay.includes('silero');
|
|
443
445
|
const text = String(p.text || p.prompt || (isKokoro
|
|
444
446
|
? 'Hello! Local Kokoro-82M speech synthesis in WORK is working smoothly.'
|
|
445
447
|
: 'Привет! Проверка локального синтеза речи WORK.')).trim();
|
|
@@ -447,7 +449,7 @@ async function runSingleModelSmokeTest(ai, p = {}) {
|
|
|
447
449
|
text,
|
|
448
450
|
language: p.language,
|
|
449
451
|
instructions: p.instructions,
|
|
450
|
-
voice: p.voice || (isKokoro ? 'af_heart' : undefined),
|
|
452
|
+
voice: p.voice || (isKokoro ? 'af_heart' : (isSilero ? 'xenia' : undefined)),
|
|
451
453
|
seed: p.seed,
|
|
452
454
|
refAudioBase64: p.refAudioBase64,
|
|
453
455
|
refText: p.refText,
|
|
@@ -1321,11 +1323,15 @@ export const TRAINER_METHODS = Object.freeze({
|
|
|
1321
1323
|
let files = typeof p.files === 'string' && p.files.trim().startsWith('[')
|
|
1322
1324
|
? JSON.parse(p.files)
|
|
1323
1325
|
: Array.isArray(p.files) ? p.files : null;
|
|
1324
|
-
|
|
1326
|
+
const customFiles = Array.isArray(curated?.customFiles) && curated.customFiles.length
|
|
1327
|
+
? curated.customFiles
|
|
1328
|
+
: null;
|
|
1329
|
+
if (!files && !customFiles && Array.isArray(curated?.files) && curated.files.length)
|
|
1325
1330
|
files = curated.files;
|
|
1326
1331
|
const job = await startHuggingFaceDownload({
|
|
1327
1332
|
repoId,
|
|
1328
1333
|
files,
|
|
1334
|
+
customFiles,
|
|
1329
1335
|
quant: p.quant || 'Q8_0',
|
|
1330
1336
|
revision: p.revision || 'main',
|
|
1331
1337
|
token: p.token || '',
|
|
@@ -380,6 +380,18 @@ function isKokoroDirSync(weightsDir) {
|
|
|
380
380
|
}
|
|
381
381
|
}
|
|
382
382
|
|
|
383
|
+
function isSileroTtsDirSync(weightsDir) {
|
|
384
|
+
if (!weightsDir || !fs.existsSync(weightsDir))
|
|
385
|
+
return false;
|
|
386
|
+
try {
|
|
387
|
+
const files = fs.readdirSync(weightsDir);
|
|
388
|
+
return files.some(f => /^(v\d+(?:_\d+)?_ru|ru_v\d+|silero.*)\.pt$/i.test(f) && !f.endsWith('.part'));
|
|
389
|
+
}
|
|
390
|
+
catch {
|
|
391
|
+
return false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
383
395
|
export function packagesForModality(modality = 'llm', weightsDir = '') {
|
|
384
396
|
const mod = String(modality || 'llm').toLowerCase();
|
|
385
397
|
const hasOnnx = hasOnnxModelSync(weightsDir);
|
|
@@ -399,6 +411,8 @@ export function packagesForModality(modality = 'llm', weightsDir = '') {
|
|
|
399
411
|
return ['torch', 'diffusers', 'accelerate', 'pillow', 'transformers', 'safetensors'];
|
|
400
412
|
if ((mod === 'tts' || mod === 'voice') && isPiperOnnxDirSync(weightsDir))
|
|
401
413
|
return ['piper-tts', 'onnxruntime'];
|
|
414
|
+
if ((mod === 'tts' || mod === 'voice') && isSileroTtsDirSync(weightsDir))
|
|
415
|
+
return ['torch'];
|
|
402
416
|
if ((mod === 'tts' || mod === 'voice') && isKokoroDirSync(weightsDir))
|
|
403
417
|
return ['torch', 'kokoro', 'soundfile'];
|
|
404
418
|
if (mod === 'music' || mod === 'text-to-audio')
|
|
@@ -12,6 +12,7 @@ import io
|
|
|
12
12
|
import json
|
|
13
13
|
import mmap
|
|
14
14
|
import os
|
|
15
|
+
import re
|
|
15
16
|
import struct
|
|
16
17
|
import sys
|
|
17
18
|
import threading
|
|
@@ -1669,6 +1670,126 @@ def _handle_tts_kokoro(req, cache, kokoro_files):
|
|
|
1669
1670
|
}
|
|
1670
1671
|
|
|
1671
1672
|
|
|
1673
|
+
def _find_silero_tts_file(weights_dir):
|
|
1674
|
+
if not weights_dir or not os.path.isdir(weights_dir):
|
|
1675
|
+
return None
|
|
1676
|
+
try:
|
|
1677
|
+
for fn in sorted(os.listdir(weights_dir)):
|
|
1678
|
+
low = fn.lower()
|
|
1679
|
+
if re.match(r"^(v\d+(?:_\d+)?_ru|ru_v\d+|silero.*)\.pt$", low) and not low.endswith(".part"):
|
|
1680
|
+
return os.path.join(weights_dir, fn)
|
|
1681
|
+
except Exception:
|
|
1682
|
+
return None
|
|
1683
|
+
return None
|
|
1684
|
+
|
|
1685
|
+
|
|
1686
|
+
def _clean_silero_text(text):
|
|
1687
|
+
s = str(text or "").strip()
|
|
1688
|
+
s = s.replace("«", '"').replace("»", '"').replace("—", "-").replace("–", "-")
|
|
1689
|
+
s = re.sub(r"[`*_#~^{}\[\]|<>]", " ", s)
|
|
1690
|
+
s = re.sub(r"\s+", " ", s).strip()
|
|
1691
|
+
return s or "Привет! Проверка локального синтеза речи Силеро."
|
|
1692
|
+
|
|
1693
|
+
|
|
1694
|
+
def _split_silero_chunks(text, limit=650):
|
|
1695
|
+
if len(text) <= limit:
|
|
1696
|
+
return [text]
|
|
1697
|
+
parts = re.split(r"(?<=[.!?…])\s+", text)
|
|
1698
|
+
chunks = []
|
|
1699
|
+
cur = ""
|
|
1700
|
+
for p in parts:
|
|
1701
|
+
p = p.strip()
|
|
1702
|
+
if not p:
|
|
1703
|
+
continue
|
|
1704
|
+
if len(cur) + len(p) + 1 <= limit:
|
|
1705
|
+
cur = f"{cur} {p}".strip() if cur else p
|
|
1706
|
+
else:
|
|
1707
|
+
if cur:
|
|
1708
|
+
chunks.append(cur)
|
|
1709
|
+
if len(p) <= limit:
|
|
1710
|
+
cur = p
|
|
1711
|
+
else:
|
|
1712
|
+
words = p.split(" ")
|
|
1713
|
+
cur = ""
|
|
1714
|
+
for w in words:
|
|
1715
|
+
if len(cur) + len(w) + 1 <= limit:
|
|
1716
|
+
cur = f"{cur} {w}".strip() if cur else w
|
|
1717
|
+
else:
|
|
1718
|
+
if cur:
|
|
1719
|
+
chunks.append(cur)
|
|
1720
|
+
cur = w
|
|
1721
|
+
if cur:
|
|
1722
|
+
chunks.append(cur)
|
|
1723
|
+
return chunks or [text[:limit]]
|
|
1724
|
+
|
|
1725
|
+
|
|
1726
|
+
def _handle_tts_silero(req, cache, pt_path):
|
|
1727
|
+
text = _clean_silero_text(req.get("text") or "Привет! Локальный синтез речи платформы Ворк работает.")
|
|
1728
|
+
allowed_speakers = ("xenia", "baya", "kseniya", "aidar", "eugene")
|
|
1729
|
+
want = str(req.get("voice") or "xenia").strip().lower()
|
|
1730
|
+
speaker = want if want in allowed_speakers else "xenia"
|
|
1731
|
+
sr = 48000
|
|
1732
|
+
|
|
1733
|
+
key = ("tts_silero", pt_path)
|
|
1734
|
+
was_cached = key in cache
|
|
1735
|
+
t_load0 = time.time()
|
|
1736
|
+
if not was_cached:
|
|
1737
|
+
try:
|
|
1738
|
+
if hasattr(torch, "set_num_threads"):
|
|
1739
|
+
torch.set_num_threads(max(1, min(8, os.cpu_count() or 4)))
|
|
1740
|
+
except Exception:
|
|
1741
|
+
pass
|
|
1742
|
+
mdl = torch.package.PackageImporter(pt_path).load_pickle("tts_models", "model")
|
|
1743
|
+
mdl.to(torch.device("cpu"))
|
|
1744
|
+
cache[key] = mdl
|
|
1745
|
+
load_ms = 0 if was_cached else int((time.time() - t_load0) * 1000)
|
|
1746
|
+
mdl = cache[key]
|
|
1747
|
+
|
|
1748
|
+
t_gen0 = time.time()
|
|
1749
|
+
audio_parts = []
|
|
1750
|
+
with torch.inference_mode():
|
|
1751
|
+
for chunk in _split_silero_chunks(text):
|
|
1752
|
+
try:
|
|
1753
|
+
wav = mdl.apply_tts(
|
|
1754
|
+
text=chunk,
|
|
1755
|
+
speaker=speaker,
|
|
1756
|
+
sample_rate=sr,
|
|
1757
|
+
put_accent=True,
|
|
1758
|
+
put_yo=True,
|
|
1759
|
+
)
|
|
1760
|
+
except TypeError:
|
|
1761
|
+
wav = mdl.apply_tts(text=chunk, speaker=speaker, sample_rate=sr)
|
|
1762
|
+
except Exception as e:
|
|
1763
|
+
# На моделях v2/16kHz 48000 может быть недоступен — откатываемся на 24000 / 16000
|
|
1764
|
+
if "sample_rate" in str(e).lower() or "48000" in str(e):
|
|
1765
|
+
sr = 24000
|
|
1766
|
+
try:
|
|
1767
|
+
wav = mdl.apply_tts(text=chunk, speaker=speaker, sample_rate=sr)
|
|
1768
|
+
except Exception:
|
|
1769
|
+
sr = 16000
|
|
1770
|
+
wav = mdl.apply_tts(text=chunk, speaker=speaker, sample_rate=sr)
|
|
1771
|
+
else:
|
|
1772
|
+
raise
|
|
1773
|
+
if wav is not None:
|
|
1774
|
+
audio_parts.append(wav.detach().cpu().float().flatten())
|
|
1775
|
+
|
|
1776
|
+
if not audio_parts:
|
|
1777
|
+
raise RuntimeError(json.dumps({"error": "Silero TTS не вернул аудиоданные для переданного текста."}))
|
|
1778
|
+
full_wav = torch.cat(audio_parts) if len(audio_parts) > 1 else audio_parts[0]
|
|
1779
|
+
gen_ms = max(1, int((time.time() - t_gen0) * 1000))
|
|
1780
|
+
return {
|
|
1781
|
+
"audioBase64": _pcm_to_wav_base64(full_wav, sr),
|
|
1782
|
+
"sampleRate": sr,
|
|
1783
|
+
"ttsKind": "silero",
|
|
1784
|
+
"voiceUsed": speaker,
|
|
1785
|
+
"instructUsed": "",
|
|
1786
|
+
"device": "CPU (Silero v5)",
|
|
1787
|
+
"loadMs": load_ms,
|
|
1788
|
+
"genMs": gen_ms,
|
|
1789
|
+
"durationMs": gen_ms,
|
|
1790
|
+
}
|
|
1791
|
+
|
|
1792
|
+
|
|
1672
1793
|
def handle_tts(req, cache):
|
|
1673
1794
|
weights_dir = req["weightsDir"]
|
|
1674
1795
|
piper_files = _find_piper_onnx_files(weights_dir)
|
|
@@ -1677,6 +1798,9 @@ def handle_tts(req, cache):
|
|
|
1677
1798
|
kokoro_files = _find_kokoro_files(weights_dir)
|
|
1678
1799
|
if kokoro_files:
|
|
1679
1800
|
return _handle_tts_kokoro(req, cache, kokoro_files)
|
|
1801
|
+
silero_pt = _find_silero_tts_file(weights_dir)
|
|
1802
|
+
if silero_pt:
|
|
1803
|
+
return _handle_tts_silero(req, cache, silero_pt)
|
|
1680
1804
|
text = str(req.get("text", "")).strip()
|
|
1681
1805
|
language = _tts_language(req.get("language") or "Russian")
|
|
1682
1806
|
instructions = str(req.get("instructions") or "").strip()
|
|
@@ -2139,8 +2263,11 @@ def main():
|
|
|
2139
2263
|
elif op == "video":
|
|
2140
2264
|
needed.extend(["diffusers", "accelerate", "pillow", "transformers", "imageio", "imageio-ffmpeg"])
|
|
2141
2265
|
elif op == "tts":
|
|
2142
|
-
|
|
2266
|
+
w_dir_arg = str(req.get("weightsDir") or "")
|
|
2267
|
+
if _find_kokoro_files(w_dir_arg):
|
|
2143
2268
|
needed.extend(["kokoro", "soundfile"])
|
|
2269
|
+
elif _find_silero_tts_file(w_dir_arg):
|
|
2270
|
+
pass # torch уже в needed
|
|
2144
2271
|
else:
|
|
2145
2272
|
needed.extend(["qwen-tts", "soundfile", "transformers"])
|
|
2146
2273
|
elif op == "music":
|