iobroker.assistant 1.9.0 → 1.10.0
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/README.md +9 -158
- package/admin/custom/.vite/manifest.json +1 -1
- package/admin/custom/assets/Components-Do2er6qU.js +2 -0
- package/admin/custom/customComponents.js +1 -1
- package/admin/custom/i18n/de.json +5 -0
- package/admin/custom/i18n/en.json +5 -0
- package/admin/custom/i18n/es.json +5 -0
- package/admin/custom/i18n/fr.json +5 -0
- package/admin/custom/i18n/it.json +5 -0
- package/admin/custom/i18n/nl.json +5 -0
- package/admin/custom/i18n/pl.json +5 -0
- package/admin/custom/i18n/pt.json +5 -0
- package/admin/custom/i18n/ru.json +5 -0
- package/admin/custom/i18n/uk.json +5 -0
- package/admin/custom/i18n/zh-cn.json +5 -0
- package/admin/custom/index.html +1 -1
- package/admin/custom/mf-manifest.json +1 -1
- package/admin/custom/mf-stats.json +1 -1
- package/admin/i18n/de.json +5 -5
- package/admin/i18n/en.json +5 -5
- package/admin/i18n/es.json +6 -6
- package/admin/i18n/fr.json +6 -6
- package/admin/i18n/it.json +6 -6
- package/admin/i18n/nl.json +6 -6
- package/admin/i18n/pl.json +6 -6
- package/admin/i18n/pt.json +6 -6
- package/admin/i18n/ru.json +5 -5
- package/admin/i18n/uk.json +6 -6
- package/admin/i18n/zh-cn.json +6 -6
- package/admin/jsonConfig.json +9 -9
- package/build/lib/installer.js +1 -1
- package/build/lib/installer.js.map +1 -1
- package/build/lib/messages.js +17 -0
- package/build/lib/messages.js.map +1 -0
- package/build/lib/voice/engines.js.map +1 -1
- package/build/lib/voice/esphome.js +5 -1
- package/build/lib/voice/esphome.js.map +1 -1
- package/build/lib/voice/parakeet.js +12 -3
- package/build/lib/voice/parakeet.js.map +1 -1
- package/build/lib/voice/wakeWords.js +154 -4
- package/build/lib/voice/wakeWords.js.map +1 -1
- package/build/main.js +125 -16
- package/build/main.js.map +1 -1
- package/io-package.json +27 -27
- package/package.json +6 -3
- package/wake-word/20261103-085427-9b0f-microwakeword-iobroker.json +19 -0
- package/wake-word/20261103-085427-9b0f-microwakeword-iobroker.tflite +0 -0
- package/wake-word/alisa.json +18 -0
- package/wake-word/alisa.tflite +0 -0
- package/wake-word/hey_bro.json +18 -0
- package/wake-word/hey_bro.tflite +0 -0
- package/admin/custom/assets/Components-BZeMTVhf.js +0 -2
package/admin/i18n/it.json
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"Without an LLM provider only the local tiers answer: the rule-based commands, routines, timers and alarms, and the local model if enabled. Anything else gets a short \"I can't do that\" reply.": "Senza un provider LLM rispondono solo i livelli locali: i comandi basati su regole, le routine, i timer e le sveglie e il modello locale, se attivato. Tutto il resto riceve una breve risposta «Non posso farlo».",
|
|
192
192
|
"Chat": "Chat",
|
|
193
193
|
"Chat history (hours)": "Chat history (hours)",
|
|
194
|
-
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "
|
|
194
|
+
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "Per quanto tempo la scheda Chat mostra le richieste passate da tutte le fonti (satelliti, Telegram, script) con parola di attivazione, livello di risposta, strumenti e id degli stati. 0 = non registrare nulla.",
|
|
195
195
|
"YouTube players": "Lettori YouTube",
|
|
196
196
|
"Player": "Lettore",
|
|
197
197
|
"TV power (optional)": "Accensione TV (opzionale)",
|
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "Verifica ffmpeg",
|
|
231
231
|
"Download ffmpeg": "Scarica ffmpeg",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "Scarica un ffmpeg statico (ffmpeg-static, 20-30 MB) nella directory dei dati dell'istanza. Viene usato quando non è indicato alcun percorso.",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice (adattatore locale)",
|
|
234
|
+
"ioBroker.voice instance": "Istanza di ioBroker.voice",
|
|
235
|
+
"Install ioBroker.voice": "Installa ioBroker.voice",
|
|
236
236
|
"Install pi-agent": "Installa pi-agent",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "Installa l'adattatore pi-agent sull'host di questa istanza e ne crea un'istanza. Richiede alcuni minuti. Poi scegli il suo modello nelle sue impostazioni oppure usa le impostazioni IA di sistema di admin.",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "Installa l'adattatore ioBroker.voice sull'host di questa istanza e ne crea un'istanza. Richiede alcuni minuti. Al primo avvio scarica il modello vocale (circa 670 MB); poi gli servono circa 1,1 GB di memoria.",
|
|
239
239
|
"Install": "Installa",
|
|
240
240
|
"Cancel": "Annulla",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s è stato installato e selezionato. Salva le impostazioni per usarlo.",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s è già installato e ora è selezionato. Salva le impostazioni per usarlo.",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "L'adattatore ioBroker.voice riconosce la voce offline sulla CPU del suo host, in 25 lingue europee che il modello rileva da solo. L'audio gli arriva tramite il bus dei messaggi di ioBroker, quindi l'istanza può anche girare su un altro host.",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "URL del modello locale (GGUF, vecchia impostazione)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "Usato solo finché nella scheda \"Modelli locali\" non è scelto un modello. Scegli il modello lì.",
|
|
246
246
|
"Local models": "Modelli locali",
|
package/admin/i18n/nl.json
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"Without an LLM provider only the local tiers answer: the rule-based commands, routines, timers and alarms, and the local model if enabled. Anything else gets a short \"I can't do that\" reply.": "Zonder LLM-provider antwoorden alleen de lokale niveaus: de op regels gebaseerde opdrachten, routines, timers en wekkers, en het lokale model indien ingeschakeld. Al het andere krijgt een kort \"Dat kan ik niet\"-antwoord.",
|
|
192
192
|
"Chat": "Chat",
|
|
193
193
|
"Chat history (hours)": "Chat history (hours)",
|
|
194
|
-
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "
|
|
194
|
+
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "Hoe lang het tabblad Chat eerdere verzoeken uit alle bronnen (satellieten, Telegram, scripts) toont, met wekwoord, antwoordniveau, tools en state-id's. 0 = niets vastleggen.",
|
|
195
195
|
"YouTube players": "YouTube-spelers",
|
|
196
196
|
"Player": "Speler",
|
|
197
197
|
"TV power (optional)": "Tv aanzetten (optioneel)",
|
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "ffmpeg controleren",
|
|
231
231
|
"Download ffmpeg": "ffmpeg downloaden",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "Downloadt een statische ffmpeg (ffmpeg-static, 20-30 MB) naar de gegevensmap van de instantie. Die wordt gebruikt als er geen pad is ingevuld.",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice (lokale adapter)",
|
|
234
|
+
"ioBroker.voice instance": "ioBroker.voice-instantie",
|
|
235
|
+
"Install ioBroker.voice": "ioBroker.voice installeren",
|
|
236
236
|
"Install pi-agent": "pi-agent installeren",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "Dit installeert de adapter pi-agent op de host van deze instantie en maakt er een instantie van aan. Dat duurt een paar minuten. Kies daarna het model in de instellingen ervan, of gebruik de systeembrede AI-instellingen van admin.",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "Dit installeert de adapter ioBroker.voice op de host van deze instantie en maakt er een instantie van aan. Dat duurt een paar minuten. Bij de eerste start downloadt hij het spraakmodel (ongeveer 670 MB); daarna heeft hij ongeveer 1,1 GB geheugen nodig.",
|
|
239
239
|
"Install": "Installeren",
|
|
240
240
|
"Cancel": "Annuleren",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s is geïnstalleerd en geselecteerd. Sla de instellingen op om hem te gebruiken.",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s is al geïnstalleerd en nu geselecteerd. Sla de instellingen op om hem te gebruiken.",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "De adapter ioBroker.voice herkent spraak offline op de CPU van zijn host, in 25 Europese talen die het model zelf herkent. Het geluid gaat via de berichtenbus van ioBroker naar hem toe, dus de instantie kan ook op een andere host draaien.",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "URL van het lokale model (GGUF, oude instelling)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "Alleen gebruikt zolang er op het tabblad \"Lokale modellen\" geen model is gekozen. Kies het model daar.",
|
|
246
246
|
"Local models": "Lokale modellen",
|
package/admin/i18n/pl.json
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"Without an LLM provider only the local tiers answer: the rule-based commands, routines, timers and alarms, and the local model if enabled. Anything else gets a short \"I can't do that\" reply.": "Bez dostawcy LLM odpowiadają tylko poziomy lokalne: polecenia oparte na regułach, rutyny, minutniki i budziki oraz model lokalny, jeśli jest włączony. Na wszystko inne pada krótka odpowiedź „Nie potrafię tego”.",
|
|
192
192
|
"Chat": "Czat",
|
|
193
193
|
"Chat history (hours)": "Chat history (hours)",
|
|
194
|
-
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "
|
|
194
|
+
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "Jak długo karta Czat pokazuje wcześniejsze zapytania ze wszystkich źródeł (satelity, Telegram, skrypty) ze słowem wybudzającym, poziomem odpowiedzi, narzędziami i identyfikatorami stanów. 0 = nic nie zapisuj.",
|
|
195
195
|
"YouTube players": "Odtwarzacze YouTube",
|
|
196
196
|
"Player": "Odtwarzacz",
|
|
197
197
|
"TV power (optional)": "Zasilanie TV (opcjonalnie)",
|
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "Sprawdź ffmpeg",
|
|
231
231
|
"Download ffmpeg": "Pobierz ffmpeg",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "Pobiera statyczny ffmpeg (ffmpeg-static, 20–30 MB) do katalogu danych instancji. Jest używany, gdy nie podano ścieżki.",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice (lokalny adapter)",
|
|
234
|
+
"ioBroker.voice instance": "Instancja ioBroker.voice",
|
|
235
|
+
"Install ioBroker.voice": "Zainstaluj ioBroker.voice",
|
|
236
236
|
"Install pi-agent": "Zainstaluj pi-agent",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "Instaluje adapter pi-agent na hoście tej instancji i tworzy jego instancję. Trwa to kilka minut. Następnie wybierz model w jego ustawieniach albo użyj ogólnosystemowych ustawień AI w admin.",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "Instaluje adapter ioBroker.voice na hoście tej instancji i tworzy jego instancję. Trwa to kilka minut. Przy pierwszym uruchomieniu pobiera model mowy (około 670 MB); potem potrzebuje około 1,1 GB pamięci.",
|
|
239
239
|
"Install": "Zainstaluj",
|
|
240
240
|
"Cancel": "Anuluj",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s został zainstalowany i wybrany. Zapisz ustawienia, aby go używać.",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s jest już zainstalowany i teraz wybrany. Zapisz ustawienia, aby go używać.",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "Adapter ioBroker.voice rozpoznaje mowę offline na procesorze swojego hosta, w 25 językach europejskich, które model rozpoznaje sam. Dźwięk trafia do niego przez magistralę wiadomości ioBroker, więc instancja może też działać na innym hoście.",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "URL modelu lokalnego (GGUF, stare ustawienie)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "Używane tylko, dopóki na karcie „Modele lokalne” nie wybrano modelu. Wybierz model tam.",
|
|
246
246
|
"Local models": "Modele lokalne",
|
package/admin/i18n/pt.json
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"Without an LLM provider only the local tiers answer: the rule-based commands, routines, timers and alarms, and the local model if enabled. Anything else gets a short \"I can't do that\" reply.": "Sem fornecedor de LLM, apenas os níveis locais respondem: os comandos baseados em regras, as rotinas, os temporizadores e alarmes e o modelo local, se ativado. Tudo o resto recebe uma breve resposta «Não consigo fazer isso».",
|
|
192
192
|
"Chat": "Chat",
|
|
193
193
|
"Chat history (hours)": "Chat history (hours)",
|
|
194
|
-
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "
|
|
194
|
+
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "Durante quanto tempo o separador Chat mostra pedidos anteriores de todas as fontes (satélites, Telegram, scripts) com palavra de ativação, nível de resposta, ferramentas e ids de estados. 0 = não registar nada.",
|
|
195
195
|
"YouTube players": "Leitores do YouTube",
|
|
196
196
|
"Player": "Leitor",
|
|
197
197
|
"TV power (optional)": "Ligar TV (opcional)",
|
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "Verificar ffmpeg",
|
|
231
231
|
"Download ffmpeg": "Transferir ffmpeg",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "Transfere um ffmpeg estático (ffmpeg-static, 20-30 MB) para o diretório de dados da instância. É usado quando nenhum caminho é indicado.",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice (adaptador local)",
|
|
234
|
+
"ioBroker.voice instance": "Instância do ioBroker.voice",
|
|
235
|
+
"Install ioBroker.voice": "Instalar ioBroker.voice",
|
|
236
236
|
"Install pi-agent": "Instalar pi-agent",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "Isto instala o adaptador pi-agent no host desta instância e cria uma instância dele. Demora alguns minutos. Depois escolha o modelo nas configurações dele ou use as configurações de IA de todo o sistema do admin.",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "Isto instala o adaptador ioBroker.voice no host desta instância e cria uma instância dele. Demora alguns minutos. No primeiro arranque transfere o modelo de voz (cerca de 670 MB); depois precisa de cerca de 1,1 GB de memória.",
|
|
239
239
|
"Install": "Instalar",
|
|
240
240
|
"Cancel": "Cancelar",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s foi instalado e selecionado. Guarde as configurações para o usar.",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s já está instalado e agora está selecionado. Guarde as configurações para o usar.",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "O adaptador ioBroker.voice reconhece a fala offline no CPU do seu host, em 25 línguas europeias que o modelo deteta sozinho. O áudio chega-lhe pelo barramento de mensagens do ioBroker, por isso a instância também pode correr noutro host.",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "URL do modelo local (GGUF, configuração antiga)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "Usado apenas enquanto nenhum modelo estiver escolhido na aba \"Modelos locais\". Escolha o modelo lá.",
|
|
246
246
|
"Local models": "Modelos locais",
|
package/admin/i18n/ru.json
CHANGED
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "Проверить ffmpeg",
|
|
231
231
|
"Download ffmpeg": "Загрузить ffmpeg",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "Загружает статический ffmpeg (ffmpeg-static, 20–30 МБ) в каталог данных экземпляра. Используется, если путь не указан.",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice (локальный адаптер)",
|
|
234
|
+
"ioBroker.voice instance": "Экземпляр ioBroker.voice",
|
|
235
|
+
"Install ioBroker.voice": "Установить ioBroker.voice",
|
|
236
236
|
"Install pi-agent": "Установить pi-agent",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "Адаптер pi-agent будет установлен на хост этого экземпляра, и будет создан его экземпляр. Это займёт несколько минут. Затем выберите модель в его настройках или используйте общесистемные настройки ИИ в admin.",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "Адаптер ioBroker.voice будет установлен на хост этого экземпляра, и будет создан его экземпляр. Это займёт несколько минут. При первом запуске он скачает речевую модель (около 670 МБ); затем ему нужно около 1,1 ГБ памяти.",
|
|
239
239
|
"Install": "Установить",
|
|
240
240
|
"Cancel": "Отмена",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s установлен и выбран. Сохраните настройки, чтобы им пользоваться.",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s уже установлен и теперь выбран. Сохраните настройки, чтобы им пользоваться.",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "Адаптер ioBroker.voice распознаёт речь офлайн на процессоре своего хоста, на 25 европейских языках, которые модель определяет сама. Аудио идёт к нему через шину сообщений ioBroker, поэтому экземпляр может работать и на другом хосте.",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "URL локальной модели (GGUF, старая настройка)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "Используется, только пока на вкладке «Локальные модели» не выбрана модель. Лучше выберите модель там.",
|
|
246
246
|
"Local models": "Локальные модели",
|
package/admin/i18n/uk.json
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"Without an LLM provider only the local tiers answer: the rule-based commands, routines, timers and alarms, and the local model if enabled. Anything else gets a short \"I can't do that\" reply.": "Без LLM-провайдера відповідають лише локальні рівні: команди на основі правил, рутини, таймери й будильники, а також локальна модель, якщо її ввімкнено. На все інше буде коротка відповідь «Цього я не вмію».",
|
|
192
192
|
"Chat": "Чат",
|
|
193
193
|
"Chat history (hours)": "Chat history (hours)",
|
|
194
|
-
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "
|
|
194
|
+
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "Як довго вкладка «Чат» показує минулі запити з усіх джерел (сателіти, Telegram, скрипти) зі словом активації, рівнем відповіді, інструментами та id станів. 0 = нічого не записувати.",
|
|
195
195
|
"YouTube players": "Плеєри YouTube",
|
|
196
196
|
"Player": "Плеєр",
|
|
197
197
|
"TV power (optional)": "Живлення ТВ (необов’язково)",
|
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "Перевірити ffmpeg",
|
|
231
231
|
"Download ffmpeg": "Завантажити ffmpeg",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "Завантажує статичний ffmpeg (ffmpeg-static, 20–30 МБ) до каталогу даних екземпляра. Використовується, якщо шлях не вказано.",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice (локальний адаптер)",
|
|
234
|
+
"ioBroker.voice instance": "Екземпляр ioBroker.voice",
|
|
235
|
+
"Install ioBroker.voice": "Встановити ioBroker.voice",
|
|
236
236
|
"Install pi-agent": "Встановити pi-agent",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "Адаптер pi-agent буде встановлено на хост цього екземпляра, і буде створено його екземпляр. Це займе кілька хвилин. Потім виберіть модель у його налаштуваннях або використайте загальносистемні налаштування ШІ в admin.",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "Адаптер ioBroker.voice буде встановлено на хост цього екземпляра, і буде створено його екземпляр. Це займе кілька хвилин. Під час першого запуску він завантажить мовну модель (близько 670 МБ); потім йому потрібно близько 1,1 ГБ пам'яті.",
|
|
239
239
|
"Install": "Встановити",
|
|
240
240
|
"Cancel": "Скасувати",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s встановлено та вибрано. Збережіть налаштування, щоб ним користуватися.",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s вже встановлено, і тепер його вибрано. Збережіть налаштування, щоб ним користуватися.",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "Адаптер ioBroker.voice розпізнає мовлення офлайн на процесорі свого хоста, 25 європейськими мовами, які модель визначає сама. Аудіо йде до нього через шину повідомлень ioBroker, тож екземпляр може працювати й на іншому хості.",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "URL локальної моделі (GGUF, старе налаштування)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "Використовується, лише поки на вкладці «Локальні моделі» не вибрано модель. Краще виберіть модель там.",
|
|
246
246
|
"Local models": "Локальні моделі",
|
package/admin/i18n/zh-cn.json
CHANGED
|
@@ -191,7 +191,7 @@
|
|
|
191
191
|
"Without an LLM provider only the local tiers answer: the rule-based commands, routines, timers and alarms, and the local model if enabled. Anything else gets a short \"I can't do that\" reply.": "没有 LLM 提供商时,只有本地层级会作答:基于规则的命令、例程、定时器和闹钟,以及已启用的本地模型。其他请求只会得到一句简短的“我做不到”。",
|
|
192
192
|
"Chat": "聊天",
|
|
193
193
|
"Chat history (hours)": "Chat history (hours)",
|
|
194
|
-
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "
|
|
194
|
+
"How long the Chat tab shows past requests from all sources (satellites, Telegram, scripts) with wake word, answering tier, tools and state ids. 0 = record nothing.": "聊天选项卡显示来自所有来源(卫星、Telegram、脚本)的历史请求的时长,包括唤醒词、应答层级、工具和状态 ID。0 = 不记录。",
|
|
195
195
|
"YouTube players": "YouTube 播放器",
|
|
196
196
|
"Player": "播放器",
|
|
197
197
|
"TV power (optional)": "电视电源(可选)",
|
|
@@ -230,17 +230,17 @@
|
|
|
230
230
|
"Check ffmpeg": "检查 ffmpeg",
|
|
231
231
|
"Download ffmpeg": "下载 ffmpeg",
|
|
232
232
|
"Downloads a static ffmpeg (ffmpeg-static, 20-30 MB) into the data directory of the instance. It is used when no path is entered.": "将静态 ffmpeg(ffmpeg-static,20–30 MB)下载到实例的数据目录。未填写路径时使用它。",
|
|
233
|
-
"
|
|
234
|
-
"
|
|
235
|
-
"Install
|
|
233
|
+
"ioBroker.voice (local adapter)": "ioBroker.voice(本地适配器)",
|
|
234
|
+
"ioBroker.voice instance": "ioBroker.voice 实例",
|
|
235
|
+
"Install ioBroker.voice": "安装 ioBroker.voice",
|
|
236
236
|
"Install pi-agent": "安装 pi-agent",
|
|
237
237
|
"This installs the adapter pi-agent on the host of this instance and creates an instance of it. It takes a few minutes. Afterwards choose its model in its settings, or use the system-wide AI settings of admin.": "这会在本实例所在的主机上安装适配器 pi-agent 并创建一个实例。需要几分钟。之后请在其设置中选择模型,或使用 admin 的系统级 AI 设置。",
|
|
238
|
-
"This installs the adapter
|
|
238
|
+
"This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.": "这会在本实例所在的主机上安装适配器 ioBroker.voice 并创建一个实例。需要几分钟。首次启动时它会下载语音模型(约 670 MB),之后需要约 1.1 GB 内存。",
|
|
239
239
|
"Install": "安装",
|
|
240
240
|
"Cancel": "取消",
|
|
241
241
|
"%s was installed and selected. Save the settings to use it.": "%s 已安装并选中。保存设置后即可使用。",
|
|
242
242
|
"%s is already installed and is now selected. Save the settings to use it.": "%s 已经安装,现已选中。保存设置后即可使用。",
|
|
243
|
-
"The adapter
|
|
243
|
+
"The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.": "适配器 ioBroker.voice 在其主机的 CPU 上离线识别语音,支持 25 种欧洲语言,语言由模型自动识别。音频通过 ioBroker 消息总线发送给它,因此该实例也可以运行在另一台主机上。",
|
|
244
244
|
"Local model URL (GGUF, old setting)": "本地模型 URL(GGUF,旧设置)",
|
|
245
245
|
"Used only while no model is selected in the tab \"Local models\". Pick the model there instead.": "仅在“本地模型”选项卡中未选择模型时使用。请在那里选择模型。",
|
|
246
246
|
"Local models": "本地模型",
|
package/admin/jsonConfig.json
CHANGED
|
@@ -963,7 +963,7 @@
|
|
|
963
963
|
{ "label": "Azure Speech", "value": "azure" },
|
|
964
964
|
{ "label": "AWS Transcribe", "value": "aws" },
|
|
965
965
|
{ "label": "Vosk (local)", "value": "vosk" },
|
|
966
|
-
{ "label": "
|
|
966
|
+
{ "label": "ioBroker.voice (local adapter)", "value": "parakeet" }
|
|
967
967
|
],
|
|
968
968
|
"default": "openai",
|
|
969
969
|
"hidden": "!data.voiceEnabled",
|
|
@@ -1003,7 +1003,7 @@
|
|
|
1003
1003
|
{ "label": "Azure Speech", "value": "azure" },
|
|
1004
1004
|
{ "label": "AWS Transcribe", "value": "aws" },
|
|
1005
1005
|
{ "label": "Vosk (local)", "value": "vosk" },
|
|
1006
|
-
{ "label": "
|
|
1006
|
+
{ "label": "ioBroker.voice (local adapter)", "value": "parakeet" }
|
|
1007
1007
|
],
|
|
1008
1008
|
"default": "",
|
|
1009
1009
|
"hidden": "!data.voiceEnabled",
|
|
@@ -1050,8 +1050,8 @@
|
|
|
1050
1050
|
"parakeetInstance": {
|
|
1051
1051
|
"newLine": true,
|
|
1052
1052
|
"type": "instance",
|
|
1053
|
-
"adapter": "
|
|
1054
|
-
"label": "
|
|
1053
|
+
"adapter": "voice",
|
|
1054
|
+
"label": "ioBroker.voice instance",
|
|
1055
1055
|
"hidden": "!data.voiceEnabled || (data.sttProvider !== 'parakeet' && data.sttFallback !== 'parakeet')",
|
|
1056
1056
|
"xs": 12,
|
|
1057
1057
|
"sm": 6,
|
|
@@ -1061,15 +1061,15 @@
|
|
|
1061
1061
|
},
|
|
1062
1062
|
"_installParakeet": {
|
|
1063
1063
|
"type": "sendTo",
|
|
1064
|
-
"label": "Install
|
|
1064
|
+
"label": "Install ioBroker.voice",
|
|
1065
1065
|
"command": "installAdapter",
|
|
1066
|
-
"jsonData": "{\"adapter\":\"
|
|
1066
|
+
"jsonData": "{\"adapter\":\"voice\"}",
|
|
1067
1067
|
"useNative": true,
|
|
1068
1068
|
"showProcess": true,
|
|
1069
1069
|
"variant": "outlined",
|
|
1070
1070
|
"confirm": {
|
|
1071
|
-
"title": "Install
|
|
1072
|
-
"text": "This installs the adapter
|
|
1071
|
+
"title": "Install ioBroker.voice",
|
|
1072
|
+
"text": "This installs the adapter ioBroker.voice on the host of this instance and creates an instance of it. It takes a few minutes. On its first start it downloads the speech model (about 670 MB); it then needs about 1.1 GB of memory.",
|
|
1073
1073
|
"ok": "Install",
|
|
1074
1074
|
"cancel": "Cancel"
|
|
1075
1075
|
},
|
|
@@ -1087,7 +1087,7 @@
|
|
|
1087
1087
|
"_parakeetInfo": {
|
|
1088
1088
|
"newLine": true,
|
|
1089
1089
|
"type": "staticText",
|
|
1090
|
-
"text": "The adapter
|
|
1090
|
+
"text": "The adapter ioBroker.voice recognises speech offline on the CPU of its host, in 25 European languages that the model detects itself. The audio goes to it over the ioBroker message bus, so the instance may also run on another host.",
|
|
1091
1091
|
"hidden": "!data.voiceEnabled || (data.sttProvider !== 'parakeet' && data.sttFallback !== 'parakeet')",
|
|
1092
1092
|
"xs": 12,
|
|
1093
1093
|
"sm": 12,
|
package/build/lib/installer.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Installs a helper adapter (pi-agent,
|
|
3
|
+
* Installs a helper adapter (pi-agent, voice) and creates an instance of it, from a button in the settings.
|
|
4
4
|
*
|
|
5
5
|
* The host does it, as for the admin: `sendToHost(host, 'cmdExec', { id, data: 'add pi-agent' })` runs
|
|
6
6
|
* `iobroker add pi-agent` there and reports back to this instance with the messages `cmdStdout`, `cmdStderr` and
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/lib/installer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA0BH,sGAAsG;AACzF,QAAA,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC9C,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAEvC,MAAa,gBAAgB;IAMJ;IAEA;IACA;IARJ,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,IAAI,GAAG,EAAE,CAAC;IACV,GAAG,GAAG,CAAC,CAAC;IAEhB,YACqB,OAAyB;IAC1C,oDAAoD;IACnC,IAAY,EACZ,YAAY,0BAAkB;QAH9B,YAAO,GAAP,OAAO,CAAkB;QAEzB,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAqB;IAChD,CAAC;IAEJ,8FAA8F;IAC9F,aAAa,CAAC,OAAe,EAAE,OAAgB;QAC3C,IAAI,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9E,OAAO,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AAC;IACL,CAAC;CACJ;AAlID,4CAkIC;AAED,iFAAiF;AACjF,SAAS,SAAS,CAAC,MAAqB;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,wCAAwC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrG,MAAM,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,OAAO,aAAa,MAAM,CAAC,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACrF,CAAC","sourcesContent":["/**\n * Installs a helper adapter (pi-agent, ai-parakeet) and creates an instance of it, from a button in the settings.\n *\n * The host does it, as for the admin: `sendToHost(host, 'cmdExec', { id, data: 'add pi-agent' })` runs\n * `iobroker add pi-agent` there and reports back to this instance with the messages `cmdStdout`, `cmdStderr` and\n * `cmdExit` (the last one twice, because it gets lost sometimes) — {@link AdapterInstaller.handleMessage} takes them.\n *\n * `add` installs from the repository the system uses and creates an instance. An adapter that is not in that\n * repository (pi-agent is only in \"latest\") comes from npm with `url iobroker.<name>`, then `add` once more.\n */\n\nexport interface InstallerAdapter {\n sendToHost(host: string, command: string, message: ioBroker.MessagePayload): void;\n getForeignObjectAsync(id: string): Promise<ioBroker.Object | null | undefined>;\n getObjectViewAsync(\n design: 'system',\n search: 'instance',\n params: { startkey: string; endkey: string },\n ): Promise<{ rows: { id: string; value: ioBroker.Object }[] }>;\n log: ioBroker.Logger;\n}\n\nexport interface CommandResult {\n /** Exit code of the command, null when it was killed. */\n code: number | null;\n /** Its last output lines. */\n output: string[];\n}\n\ninterface Running {\n resolve: (result: CommandResult) => void;\n output: string[];\n timer: NodeJS.Timeout;\n}\n\n/** An npm install on a Raspberry Pi takes a while; a command that runs longer goes on on the host. */\nexport const COMMAND_TIMEOUT_MS = 15 * 60_000;\nconst KEEP_LINES = 30;\nconst NAME_RE = /^[a-z0-9][a-z0-9-]*$/;\n\nexport class AdapterInstaller {\n private readonly running = new Map<string, Running>();\n private busy = '';\n private seq = 0;\n\n constructor(\n private readonly adapter: InstallerAdapter,\n /** Host to install on: the one of this instance. */\n private readonly host: string,\n private readonly timeoutMs = COMMAND_TIMEOUT_MS,\n ) {}\n\n /** A `cmdStdout`/`cmdStderr`/`cmdExit` message of the host; false when it is none of ours. */\n handleMessage(command: string, message: unknown): boolean {\n if (command !== 'cmdStdout' && command !== 'cmdStderr' && command !== 'cmdExit') {\n return false;\n }\n const { id, data } = (message || {}) as { id?: unknown; data?: unknown };\n const run = typeof id === 'string' ? this.running.get(id) : undefined;\n if (!run) {\n return true; // the second cmdExit, or a command of an earlier run\n }\n if (command === 'cmdExit') {\n this.running.delete(id as string);\n clearTimeout(run.timer);\n run.resolve({ code: typeof data === 'number' ? data : null, output: run.output });\n return true;\n }\n const text = typeof data === 'string' ? data : data === undefined || data === null ? '' : JSON.stringify(data);\n for (const line of text.split(/\\r?\\n/)) {\n if (line.trim()) {\n run.output.push(line.trim());\n this.adapter.log.debug(`${this.host}: ${line.trim()}`);\n }\n }\n run.output.splice(0, Math.max(0, run.output.length - KEEP_LINES));\n return true;\n }\n\n /** Run `iobroker <cmd>` on the host. */\n run(cmd: string): Promise<CommandResult> {\n const id = `assistant-${Date.now()}-${++this.seq}`;\n this.adapter.log.info(`${this.host}: iobroker ${cmd}`);\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n this.running.delete(id);\n resolve({\n code: null,\n output: [\n `iobroker ${cmd} still runs on ${this.host} after ${Math.ceil(this.timeoutMs / 60_000)} min — see the log of the host`,\n ],\n });\n }, this.timeoutMs);\n this.running.set(id, { resolve, output: [], timer });\n this.adapter.sendToHost(this.host, 'cmdExec', { id, data: cmd });\n });\n }\n\n /** An instance of the adapter: an enabled one first, on this host first. `pi-agent.0`, or null. */\n async findInstance(name: string): Promise<string | null> {\n const prefix = `system.adapter.${name}.`;\n const view = await this.adapter.getObjectViewAsync('system', 'instance', {\n startkey: prefix,\n endkey: `${prefix}香`,\n });\n const rank = (obj: ioBroker.Object): number =>\n (obj.common?.enabled ? 0 : 2) + ((obj.common as { host?: string })?.host === this.host ? 0 : 1);\n const rows = (view?.rows || [])\n .filter(row => row.value && /^\\d+$/.test(row.id.slice(prefix.length)))\n .sort((a, b) => rank(a.value) - rank(b.value) || a.id.localeCompare(b.id, undefined, { numeric: true }));\n return rows.length ? rows[0].id.slice('system.adapter.'.length) : null;\n }\n\n /** Install the adapter if needed and create an instance if there is none. */\n async ensure(name: string): Promise<{ instance: string; installed: boolean }> {\n if (!NAME_RE.test(name)) {\n throw new Error(`Invalid adapter name \"${name}\"`);\n }\n const existing = await this.findInstance(name);\n if (existing) {\n return { instance: existing, installed: false };\n }\n if (this.busy) {\n throw new Error(`${this.busy} is being installed right now`);\n }\n this.busy = name;\n try {\n const installed = async (): Promise<boolean> =>\n !!(await this.adapter.getForeignObjectAsync(`system.adapter.${name}`));\n let add = await this.runToEnd(`add ${name}`);\n if (!(await this.findInstance(name))) {\n if (!(await installed())) {\n // not in the repository the system uses: the newest version from npm\n const npm = await this.runToEnd(`url iobroker.${name}`);\n if (!(await installed())) {\n throw new Error(\n `${name} could not be installed — neither from the repository (${lastError(add)}) nor from npm (${lastError(npm)})`,\n );\n }\n }\n add = await this.runToEnd(`add ${name}`);\n }\n const instance = await this.findInstance(name);\n if (!instance) {\n throw new Error(`${name} is installed, but no instance was created: ${lastError(add)}`);\n }\n this.adapter.log.info(`${instance} installed on ${this.host}`);\n return { instance, installed: true };\n } finally {\n this.busy = '';\n }\n }\n\n /** {@link run}, but a command that did not end (timeout, adapter stops) ends the installation: it still runs. */\n private async runToEnd(cmd: string): Promise<CommandResult> {\n const result = await this.run(cmd);\n if (result.code === null) {\n throw new Error(result.output[result.output.length - 1] || `iobroker ${cmd} did not end`);\n }\n return result;\n }\n\n /** Ends waiting commands (the adapter stops); they go on on the host. */\n stop(): void {\n for (const [id, run] of this.running) {\n clearTimeout(run.timer);\n run.resolve({ code: null, output: ['the adapter stopped'] });\n this.running.delete(id);\n }\n }\n}\n\n/** The line that says why a command failed: an error line, else the last one. */\nfunction lastError(result: CommandResult): string {\n const lines = result.output;\n const error = [...lines].reverse().find(line => /error|unknown|not found|cannot|failed/i.test(line));\n const line = error || lines[lines.length - 1] || '';\n return `exit code ${result.code ?? '–'}${line ? `: ${line.slice(0, 300)}` : ''}`;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"installer.js","sourceRoot":"","sources":["../../src/lib/installer.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AA0BH,sGAAsG;AACzF,QAAA,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AAC9C,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,OAAO,GAAG,sBAAsB,CAAC;AAEvC,MAAa,gBAAgB;IAMJ;IAEA;IACA;IARJ,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAC9C,IAAI,GAAG,EAAE,CAAC;IACV,GAAG,GAAG,CAAC,CAAC;IAEhB,YACqB,OAAyB;IAC1C,oDAAoD;IACnC,IAAY,EACZ,YAAY,0BAAkB;QAH9B,YAAO,GAAP,OAAO,CAAkB;QAEzB,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAqB;IAChD,CAAC;IAEJ,8FAA8F;IAC9F,aAAa,CAAC,OAAe,EAAE,OAAgB;QAC3C,IAAI,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC9E,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,G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,CAAC,MAAqB;IACpC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,OAAO,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,wCAAwC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrG,MAAM,IAAI,GAAG,KAAK,IAAI,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,OAAO,aAAa,MAAM,CAAC,IAAI,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACrF,CAAC","sourcesContent":["/**\n * Installs a helper adapter (pi-agent, voice) and creates an instance of it, from a button in the settings.\n *\n * The host does it, as for the admin: `sendToHost(host, 'cmdExec', { id, data: 'add pi-agent' })` runs\n * `iobroker add pi-agent` there and reports back to this instance with the messages `cmdStdout`, `cmdStderr` and\n * `cmdExit` (the last one twice, because it gets lost sometimes) — {@link AdapterInstaller.handleMessage} takes them.\n *\n * `add` installs from the repository the system uses and creates an instance. An adapter that is not in that\n * repository (pi-agent is only in \"latest\") comes from npm with `url iobroker.<name>`, then `add` once more.\n */\n\nexport interface InstallerAdapter {\n sendToHost(host: string, command: string, message: ioBroker.MessagePayload): void;\n getForeignObjectAsync(id: string): Promise<ioBroker.Object | null | undefined>;\n getObjectViewAsync(\n design: 'system',\n search: 'instance',\n params: { startkey: string; endkey: string },\n ): Promise<{ rows: { id: string; value: ioBroker.Object }[] }>;\n log: ioBroker.Logger;\n}\n\nexport interface CommandResult {\n /** Exit code of the command, null when it was killed. */\n code: number | null;\n /** Its last output lines. */\n output: string[];\n}\n\ninterface Running {\n resolve: (result: CommandResult) => void;\n output: string[];\n timer: NodeJS.Timeout;\n}\n\n/** An npm install on a Raspberry Pi takes a while; a command that runs longer goes on on the host. */\nexport const COMMAND_TIMEOUT_MS = 15 * 60_000;\nconst KEEP_LINES = 30;\nconst NAME_RE = /^[a-z0-9][a-z0-9-]*$/;\n\nexport class AdapterInstaller {\n private readonly running = new Map<string, Running>();\n private busy = '';\n private seq = 0;\n\n constructor(\n private readonly adapter: InstallerAdapter,\n /** Host to install on: the one of this instance. */\n private readonly host: string,\n private readonly timeoutMs = COMMAND_TIMEOUT_MS,\n ) {}\n\n /** A `cmdStdout`/`cmdStderr`/`cmdExit` message of the host; false when it is none of ours. */\n handleMessage(command: string, message: unknown): boolean {\n if (command !== 'cmdStdout' && command !== 'cmdStderr' && command !== 'cmdExit') {\n return false;\n }\n const { id, data } = (message || {}) as { id?: unknown; data?: unknown };\n const run = typeof id === 'string' ? this.running.get(id) : undefined;\n if (!run) {\n return true; // the second cmdExit, or a command of an earlier run\n }\n if (command === 'cmdExit') {\n this.running.delete(id as string);\n clearTimeout(run.timer);\n run.resolve({ code: typeof data === 'number' ? data : null, output: run.output });\n return true;\n }\n const text = typeof data === 'string' ? data : data === undefined || data === null ? '' : JSON.stringify(data);\n for (const line of text.split(/\\r?\\n/)) {\n if (line.trim()) {\n run.output.push(line.trim());\n this.adapter.log.debug(`${this.host}: ${line.trim()}`);\n }\n }\n run.output.splice(0, Math.max(0, run.output.length - KEEP_LINES));\n return true;\n }\n\n /** Run `iobroker <cmd>` on the host. */\n run(cmd: string): Promise<CommandResult> {\n const id = `assistant-${Date.now()}-${++this.seq}`;\n this.adapter.log.info(`${this.host}: iobroker ${cmd}`);\n return new Promise(resolve => {\n const timer = setTimeout(() => {\n this.running.delete(id);\n resolve({\n code: null,\n output: [\n `iobroker ${cmd} still runs on ${this.host} after ${Math.ceil(this.timeoutMs / 60_000)} min — see the log of the host`,\n ],\n });\n }, this.timeoutMs);\n this.running.set(id, { resolve, output: [], timer });\n this.adapter.sendToHost(this.host, 'cmdExec', { id, data: cmd });\n });\n }\n\n /** An instance of the adapter: an enabled one first, on this host first. `pi-agent.0`, or null. */\n async findInstance(name: string): Promise<string | null> {\n const prefix = `system.adapter.${name}.`;\n const view = await this.adapter.getObjectViewAsync('system', 'instance', {\n startkey: prefix,\n endkey: `${prefix}香`,\n });\n const rank = (obj: ioBroker.Object): number =>\n (obj.common?.enabled ? 0 : 2) + ((obj.common as { host?: string })?.host === this.host ? 0 : 1);\n const rows = (view?.rows || [])\n .filter(row => row.value && /^\\d+$/.test(row.id.slice(prefix.length)))\n .sort((a, b) => rank(a.value) - rank(b.value) || a.id.localeCompare(b.id, undefined, { numeric: true }));\n return rows.length ? rows[0].id.slice('system.adapter.'.length) : null;\n }\n\n /** Install the adapter if needed and create an instance if there is none. */\n async ensure(name: string): Promise<{ instance: string; installed: boolean }> {\n if (!NAME_RE.test(name)) {\n throw new Error(`Invalid adapter name \"${name}\"`);\n }\n const existing = await this.findInstance(name);\n if (existing) {\n return { instance: existing, installed: false };\n }\n if (this.busy) {\n throw new Error(`${this.busy} is being installed right now`);\n }\n this.busy = name;\n try {\n const installed = async (): Promise<boolean> =>\n !!(await this.adapter.getForeignObjectAsync(`system.adapter.${name}`));\n let add = await this.runToEnd(`add ${name}`);\n if (!(await this.findInstance(name))) {\n if (!(await installed())) {\n // not in the repository the system uses: the newest version from npm\n const npm = await this.runToEnd(`url iobroker.${name}`);\n if (!(await installed())) {\n throw new Error(\n `${name} could not be installed — neither from the repository (${lastError(add)}) nor from npm (${lastError(npm)})`,\n );\n }\n }\n add = await this.runToEnd(`add ${name}`);\n }\n const instance = await this.findInstance(name);\n if (!instance) {\n throw new Error(`${name} is installed, but no instance was created: ${lastError(add)}`);\n }\n this.adapter.log.info(`${instance} installed on ${this.host}`);\n return { instance, installed: true };\n } finally {\n this.busy = '';\n }\n }\n\n /** {@link run}, but a command that did not end (timeout, adapter stops) ends the installation: it still runs. */\n private async runToEnd(cmd: string): Promise<CommandResult> {\n const result = await this.run(cmd);\n if (result.code === null) {\n throw new Error(result.output[result.output.length - 1] || `iobroker ${cmd} did not end`);\n }\n return result;\n }\n\n /** Ends waiting commands (the adapter stops); they go on on the host. */\n stop(): void {\n for (const [id, run] of this.running) {\n clearTimeout(run.timer);\n run.resolve({ code: null, output: ['the adapter stopped'] });\n this.running.delete(id);\n }\n }\n}\n\n/** The line that says why a command failed: an error line, else the last one. */\nfunction lastError(result: CommandResult): string {\n const lines = result.output;\n const error = [...lines].reverse().find(line => /error|unknown|not found|cannot|failed/i.test(line));\n const line = error || lines[lines.length - 1] || '';\n return `exit code ${result.code ?? '–'}${line ? `: ${line.slice(0, 300)}` : ''}`;\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Messages that reach `onMessage` but are no request.
|
|
4
|
+
*
|
|
5
|
+
* js-controller hands a reply (`callback.ack`) to the callback that waits for it; when that callback is gone, the reply
|
|
6
|
+
* arrives as a message of its own. That happens when the adapter restarted while another adapter was still answering
|
|
7
|
+
* it: a pi-agent answer that comes after an update of the assistant. Answering such a reply sends it back with the same
|
|
8
|
+
* `callback`, and a caller that does the same keeps both adapters in a loop (field report 2026-11-13: about 25 empty
|
|
9
|
+
* `ask` a second between assistant.0 and pi-agent.0 after an update of the assistant).
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.isLateReply = isLateReply;
|
|
13
|
+
/** Whether the message is a late reply to a request of ours rather than a request. */
|
|
14
|
+
function isLateReply(obj) {
|
|
15
|
+
return !!obj?.callback?.ack;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/lib/messages.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAGH,kCAEC;AAHD,sFAAsF;AACtF,SAAgB,WAAW,CAAC,GAA+D;IACvF,OAAO,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC;AAChC,CAAC","sourcesContent":["/**\n * Messages that reach `onMessage` but are no request.\n *\n * js-controller hands a reply (`callback.ack`) to the callback that waits for it; when that callback is gone, the reply\n * arrives as a message of its own. That happens when the adapter restarted while another adapter was still answering\n * it: a pi-agent answer that comes after an update of the assistant. Answering such a reply sends it back with the same\n * `callback`, and a caller that does the same keeps both adapters in a loop (field report 2026-11-13: about 25 empty\n * `ask` a second between assistant.0 and pi-agent.0 after an update of the assistant).\n */\n\n/** Whether the message is a late reply to a request of ours rather than a request. */\nexport function isLateReply(obj: { callback?: { ack?: boolean } | null } | null | undefined): boolean {\n return !!obj?.callback?.ack;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../../src/lib/voice/engines.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,0CAYC;AA+BD,0CAGC;AA2ID,gCAmBC;AAGD,sCAKC;AAMD,sCAKC;AAvVD;;;;GAIG;AACH,+BAAkD;AAClD,+BAAoE;AACpE,mCAA8D;AAC9D,+BAAuE;AACvE,iCAAiD;AACjD,yCAA6D;AAC7D,mCAAoD;AACpD,6CAOsB;AACtB,gDAAkC;AAElC,yCAAuC;AACvC,yCAAwE;AACxE,iCAAqC;AACrC,qDAAqF;AAuErF,SAAS,YAAY,CAAC,KAAuB;IACzC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACxE,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,KAAuB;IACvC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,iEA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F;AACpF,KAAK,UAAU,aAAa,CAAC,QAAwB;IACxD,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC5B,OAAO,CAAC,MAAM,IAAA,uCAA0B,EAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * Factory that builds the configured STT/TTS engine. Cloud engines (OpenAI/Azure/AWS) use resolved\n * credentials; local engines (Vosk/Piper) download their models on demand into the data dir.\n * Adding a provider = one new engine class + one `case` here.\n */\nimport { OpenAiStt, type SttEngine } from './stt';\nimport { OpenAiTts, type OpenAiVoice, type TtsEngine } from './tts';\nimport { AzureStt, AzureTts, listAzureVoices } from './azure';\nimport { AwsStt, AwsTts, listPollyVoices, type AwsCreds } from './aws';\nimport { VoskStt, listVoskModels } from './vosk';\nimport { ParakeetStt, type MessageSender } from './parakeet';\nimport { PiperTts, listPiperVoices } from './piper';\nimport {\n OpenRouterStt,\n OpenRouterTts,\n listOpenRouterSpeechModels,\n voicesForLanguage,\n DEFAULT_OPENROUTER_TTS_MODEL,\n type AudioDecoder,\n} from './openrouter';\nimport * as path from 'node:path';\n\nimport { CachedTts } from './ttsCache';\nimport { FallbackStt, FallbackTts, type NamedEngine } from './fallback';\nimport { isoToLocale } from './lang';\nimport { LanguageTts, VoicePerLanguage, type LanguageVoice } from './speechLanguage';\nimport type { VoiceLogger } from './download';\n\nexport type SpeechProvider = 'openai' | 'openrouter' | 'azure' | 'aws' | 'vosk' | 'parakeet' | 'piper';\n\n/** All speech credentials, resolved from config (or the central credential store). */\nexport interface VoiceCredentials {\n openaiKey: string;\n openrouterKey: string;\n azureKey: string;\n azureRegion: string;\n aws: AwsCreds;\n}\n\n/** Provider-specific voice ids (each provider names voices differently). */\nexport interface VoiceNames {\n openai: string; // alloy/echo/…\n azure: string; // e.g. de-DE-KatjaNeural\n aws: string; // e.g. Vicki\n piper: string; // e.g. de_DE-thorsten-medium\n openrouter: string; // depends on the model, e.g. Kore, george\n}\n\n/** Everything the factory needs to build any engine. */\nexport interface EngineContext {\n creds: VoiceCredentials;\n voices: VoiceNames;\n /** Optional second engine, used when the primary one fails ('' = none). */\n sttFallback?: SpeechProvider | '';\n ttsFallback?: SpeechProvider | '';\n /** Writable instance data dir (for the local engines' downloads). */\n dataDir: string;\n log: VoiceLogger;\n /** Local model overrides ('' → default per language). */\n voskModel: string;\n /** OpenAI STT model ('' → 'whisper-1'; e.g. 'gpt-4o-transcribe'). */\n sttModel: string;\n /**\n * OpenAI-compatible transcription server instead of OpenAI ('' = OpenAI), e.g. a local whisper container.\n * It gets `sttServerKey`, never the OpenAI key — that one is only for OpenAI.\n */\n sttBaseUrl?: string;\n /** Key for `sttBaseUrl` ('' = the server needs none). */\n sttServerKey?: string;\n /** OpenAI TTS model ('' → 'tts-1'; e.g. 'gpt-4o-mini-tts'). */\n ttsModel: string;\n /** OpenRouter models ('' → the defaults of openrouter.ts) */\n openrouterSttModel: string;\n openrouterTtsModel: string;\n /** Decoder for compressed speech (OpenRouter models that only return mp3); absent → those models fail */\n decodeAudio?: AudioDecoder;\n /** Longest text that is spoken, in characters; longer ones are cut at a sentence end. 0 = no limit, absent = 400. */\n ttsMaxChars?: number;\n /**\n * Language the satellites listen in (ISO-639-1). A voice set for one language (Polly 'Vicki') is only used for\n * it; an answer in another language gets the default voice of that language.\n */\n language?: string;\n /**\n * Table \"voice per language\" (ISO code → voice and/or model of the main TTS provider); absent = the voices above.\n * A model only for OpenAI and OpenRouter, the others have no choice.\n */\n voicesByLanguage?: Record<string, LanguageVoice>;\n /** Language the answering tier reported for exactly this text (pi-agent `language`); absent → by its letters. */\n reportedLanguage?: (text: string) => string | undefined;\n /** Instance of ioBroker.ai-parakeet for the provider `parakeet`, e.g. 'ai-parakeet.0'. */\n parakeetInstance?: string;\n /** Message bus to other instances (ai-parakeet); absent → `parakeet` cannot be used. */\n sendMessage?: MessageSender;\n}\n\nfunction requireAzure(creds: VoiceCredentials): void {\n if (!creds.azureKey || !creds.azureRegion) {\n throw new Error('Azure speech needs a subscription key and region');\n }\n}\n\nfunction requireAws(creds: VoiceCredentials): void {\n if (!creds.aws.accessKeyId || !creds.aws.secretAccessKey || !creds.aws.region) {\n throw new Error('AWS speech needs an access key id, secret access key and region');\n }\n}\n\nfunction requireOpenAi(creds: VoiceCredentials): void {\n if (!creds.openaiKey) {\n throw new Error('OpenAI speech needs an API key');\n }\n}\n\nfunction requireOpenRouter(creds: VoiceCredentials): void {\n if (!creds.openrouterKey) {\n throw new Error('OpenRouter speech needs an API key');\n }\n}\n\nexport function createSttEngine(provider: SpeechProvider, ctx: EngineContext): SttEngine {\n const primary: NamedEngine<SttEngine> = { name: provider, engine: buildSttEngine(provider, ctx) };\n const fallback = ctx.sttFallback && ctx.sttFallback !== provider ? ctx.sttFallback : '';\n if (!fallback) {\n return primary.engine;\n }\n try {\n return new FallbackStt([primary, { name: fallback, engine: buildSttEngine(fallback, ctx) }], ctx.log);\n } catch (e) {\n ctx.log.warn(`Speech-to-text fallback '${fallback}' unavailable: ${(e as Error).message}`);\n return primary.engine;\n }\n}\n\nfunction buildSttEngine(provider: SpeechProvider, ctx: EngineContext): SttEngine {\n switch (provider) {\n case 'azure':\n requireAzure(ctx.creds);\n return new AzureStt(ctx.creds.azureKey, ctx.creds.azureRegion);\n case 'aws':\n requireAws(ctx.creds);\n return new AwsStt(ctx.creds.aws);\n case 'vosk':\n return new VoskStt(ctx.dataDir, ctx.voskModel, ctx.log);\n case 'parakeet':\n if (!ctx.sendMessage) {\n throw new Error('Parakeet speech recognition is not available here');\n }\n return new ParakeetStt((ctx.parakeetInstance || '').trim(), ctx.sendMessage);\n case 'openrouter':\n requireOpenRouter(ctx.creds);\n return new OpenRouterStt(ctx.creds.openrouterKey, ctx.openrouterSttModel);\n case 'piper':\n throw new Error('Piper is a text-to-speech engine, not speech-to-text');\n default:\n if (ctx.sttBaseUrl?.trim()) {\n return new OpenAiStt(ctx.sttServerKey || '', ctx.sttModel || undefined, ctx.sttBaseUrl);\n }\n requireOpenAi(ctx.creds);\n return new OpenAiStt(ctx.creds.openaiKey, ctx.sttModel || undefined);\n }\n}\n\nexport function createTtsEngine(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n // Outermost: every text is spoken in its own language — a German voice spells a Russian answer letter by letter\n return new LanguageTts(fallbackTts(provider, ctx), ctx.reportedLanguage, ctx.log);\n}\n\nfunction fallbackTts(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n // Each engine gets the shared behaviour (disk cache, length limit, SSML) and its own cache directory,\n // so a fallback engine's voice can never be served later while the primary one is healthy again.\n const primary: NamedEngine<TtsEngine> = { name: provider, engine: withLanguageVoices(provider, ctx) };\n const fallback = ctx.ttsFallback && ctx.ttsFallback !== provider ? ctx.ttsFallback : '';\n if (!fallback) {\n return primary.engine;\n }\n try {\n return new FallbackTts([primary, { name: fallback, engine: cachedTts(fallback, ctx) }], ctx.log);\n } catch (e) {\n // A fallback that cannot even be built (missing key, wrong provider) must not take the main one down.\n ctx.log.warn(`Text-to-speech fallback '${fallback}' unavailable: ${(e as Error).message}`);\n return primary.engine;\n }\n}\n\n/** Key of a provider in {@link VoiceNames}; the speech-to-text-only providers have no voice. */\nfunction voiceKey(provider: SpeechProvider): keyof VoiceNames | '' {\n return provider === 'vosk' || provider === 'parakeet' ? '' : provider;\n}\n\n/** Providers whose TTS model can be chosen. */\nfunction hasTtsModel(provider: SpeechProvider): boolean {\n return provider === 'openai' || provider === 'openrouter';\n}\n\n/**\n * The engine context of one row of the table \"voice per language\": its voice and model instead of the ones set above.\n * Another OpenRouter model without a voice of its own gets none — the voices belong to the model, the engine then\n * takes the first one of the model for the language.\n */\nfunction rowContext(\n provider: SpeechProvider,\n key: keyof VoiceNames,\n lang: string,\n row: LanguageVoice,\n ctx: EngineContext,\n): EngineContext {\n const model = hasTtsModel(provider) ? row.model : '';\n const otherModel =\n provider === 'openrouter' && !!model && model !== (ctx.openrouterTtsModel || DEFAULT_OPENROUTER_TTS_MODEL);\n const voice = row.voice || (otherModel ? '' : ctx.voices[key]);\n return {\n ...ctx,\n // the voice of a row is for its language (Polly names say nothing about it)\n language: lang,\n voices: { ...ctx.voices, [key]: voice },\n ttsModel: provider === 'openai' && model ? model : ctx.ttsModel,\n openrouterTtsModel: provider === 'openrouter' && model ? model : ctx.openrouterTtsModel,\n };\n}\n\n/**\n * The main provider with the table \"voice per language\": one engine per row with that voice and model. The table\n * names voices and models of the main provider, so the fallback provider does not get it.\n */\nfunction withLanguageVoices(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n const main = cachedTts(provider, ctx);\n const key = voiceKey(provider);\n const rows = Object.entries(ctx.voicesByLanguage || {});\n if (!key || !rows.length) {\n return main;\n }\n const byLanguage: Record<string, TtsEngine> = {};\n for (const [lang, row] of rows) {\n if (row.model && !hasTtsModel(provider)) {\n ctx.log.warn(`TTS model '${row.model}' for '${lang}' ignored: ${provider} has no model choice`);\n if (!row.voice) {\n continue;\n }\n }\n try {\n byLanguage[lang] = cachedTts(provider, rowContext(provider, key, lang, row, ctx));\n } catch (e) {\n ctx.log.warn(`Voice '${row.voice || row.model}' for '${lang}' unavailable: ${(e as Error).message}`);\n }\n }\n return new VoicePerLanguage(main, byLanguage);\n}\n\n/**\n * One provider binding plus the shared cache/length/SSML layer. One cache directory per provider+voice —\n * a voice change must not serve audio in the old voice.\n */\nfunction cachedTts(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n const voice =\n provider === 'azure'\n ? ctx.voices.azure\n : provider === 'aws'\n ? ctx.voices.aws\n : provider === 'piper'\n ? ctx.voices.piper\n : provider === 'openrouter'\n ? `${ctx.openrouterTtsModel || DEFAULT_OPENROUTER_TTS_MODEL}-${ctx.voices.openrouter}`\n : // the model too: another model must not serve the audio of the old one\n `${ctx.ttsModel ? `${ctx.ttsModel}-` : ''}${ctx.voices.openai}`;\n const dir = path.join(ctx.dataDir, 'ttscache', `${provider}-${(voice || 'default').replace(/[^\\w.-]/g, '_')}`);\n return new CachedTts(buildTtsEngine(provider, ctx), { dir, log: ctx.log, maxChars: ctx.ttsMaxChars });\n}\n\nfunction buildTtsEngine(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n switch (provider) {\n case 'azure':\n requireAzure(ctx.creds);\n return new AzureTts(ctx.creds.azureKey, ctx.creds.azureRegion, ctx.voices.azure);\n case 'aws':\n requireAws(ctx.creds);\n return new AwsTts(ctx.creds.aws, ctx.voices.aws, ctx.language);\n case 'piper':\n return new PiperTts(ctx.dataDir, ctx.voices.piper, ctx.log);\n case 'vosk':\n throw new Error('Vosk is a speech-to-text engine, not text-to-speech');\n case 'parakeet':\n throw new Error('Parakeet is a speech-to-text engine, not text-to-speech');\n case 'openrouter':\n requireOpenRouter(ctx.creds);\n return new OpenRouterTts(\n ctx.creds.openrouterKey,\n ctx.openrouterTtsModel,\n ctx.voices.openrouter,\n ctx.decodeAudio,\n );\n default:\n requireOpenAi(ctx.creds);\n return new OpenAiTts(\n ctx.creds.openaiKey,\n (ctx.voices.openai || 'alloy') as OpenAiVoice,\n ctx.ttsModel || undefined,\n );\n }\n}\n\n/** OpenAI TTS voices are a fixed set (no list API). */\nconst OPENAI_VOICES = ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'];\n\n/** List the available TTS voices for a provider (for the settings voice dropdown). */\nexport async function listVoices(provider: SpeechProvider, ctx: EngineContext, language: string): Promise<string[]> {\n switch (provider) {\n case 'azure':\n requireAzure(ctx.creds);\n return listAzureVoices(ctx.creds.azureKey, ctx.creds.azureRegion, isoToLocale(language));\n case 'aws':\n requireAws(ctx.creds);\n return listPollyVoices(ctx.creds.aws, isoToLocale(language));\n case 'piper':\n return listPiperVoices();\n case 'openrouter': {\n // public list, no key needed: the voices of the chosen model\n const model = ctx.openrouterTtsModel || DEFAULT_OPENROUTER_TTS_MODEL;\n const models = await listOpenRouterSpeechModels('speech');\n return voicesForLanguage(models.find(m => m.id === model)?.voices || [], language);\n }\n default:\n return OPENAI_VOICES;\n }\n}\n\n/** Suggested STT model names for the settings dropdown: the local Vosk catalogue, or the models of OpenRouter. */\nexport async function listSttModels(provider: SpeechProvider, language: string): Promise<string[]> {\n if (provider === 'openrouter') {\n return (await listOpenRouterSpeechModels('transcription')).map(m => m.id);\n }\n return provider === 'vosk' ? listVoskModels(language) : [];\n}\n\n/** OpenAI TTS models (no list API that tells speech models apart). */\nconst OPENAI_TTS_MODELS = ['tts-1', 'tts-1-hd', 'gpt-4o-mini-tts'];\n\n/** TTS model names for the settings dropdown; the other providers have no model choice. */\nexport async function listTtsModels(provider: SpeechProvider): Promise<string[]> {\n if (provider === 'openrouter') {\n return (await listOpenRouterSpeechModels('speech')).map(m => m.id);\n }\n return provider === 'openai' ? OPENAI_TTS_MODELS : [];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"engines.js","sourceRoot":"","sources":["../../../src/lib/voice/engines.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwHA,0CAYC;AA+BD,0CAGC;AA2ID,gCAmBC;AAGD,sCAKC;AAMD,sCAKC;AAvVD;;;;GAIG;AACH,+BAAkD;AAClD,+BAAoE;AACpE,mCAA8D;AAC9D,+BAAuE;AACvE,iCAAiD;AACjD,yCAA6D;AAC7D,mCAAoD;AACpD,6CAOsB;AACtB,gDAAkC;AAElC,yCAAuC;AACvC,yCAAwE;AACxE,iCAAqC;AACrC,qDAAqF;AAuErF,SAAS,YAAY,CAAC,KAAuB;IACzC,IAAI,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;IACxE,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,KAAuB;IACvC,IAAI,CAAC,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,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/D,CAAC;AAED,sEAAsE;AACtE,MAAM,iBAAiB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,iBAAiB,CAAC,CAAC;AAEnE,2FAA2F;AACpF,KAAK,UAAU,aAAa,CAAC,QAAwB;IACxD,IAAI,QAAQ,KAAK,YAAY,EAAE,CAAC;QAC5B,OAAO,CAAC,MAAM,IAAA,uCAA0B,EAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1D,CAAC","sourcesContent":["/**\n * Factory that builds the configured STT/TTS engine. Cloud engines (OpenAI/Azure/AWS) use resolved\n * credentials; local engines (Vosk/Piper) download their models on demand into the data dir.\n * Adding a provider = one new engine class + one `case` here.\n */\nimport { OpenAiStt, type SttEngine } from './stt';\nimport { OpenAiTts, type OpenAiVoice, type TtsEngine } from './tts';\nimport { AzureStt, AzureTts, listAzureVoices } from './azure';\nimport { AwsStt, AwsTts, listPollyVoices, type AwsCreds } from './aws';\nimport { VoskStt, listVoskModels } from './vosk';\nimport { ParakeetStt, type MessageSender } from './parakeet';\nimport { PiperTts, listPiperVoices } from './piper';\nimport {\n OpenRouterStt,\n OpenRouterTts,\n listOpenRouterSpeechModels,\n voicesForLanguage,\n DEFAULT_OPENROUTER_TTS_MODEL,\n type AudioDecoder,\n} from './openrouter';\nimport * as path from 'node:path';\n\nimport { CachedTts } from './ttsCache';\nimport { FallbackStt, FallbackTts, type NamedEngine } from './fallback';\nimport { isoToLocale } from './lang';\nimport { LanguageTts, VoicePerLanguage, type LanguageVoice } from './speechLanguage';\nimport type { VoiceLogger } from './download';\n\nexport type SpeechProvider = 'openai' | 'openrouter' | 'azure' | 'aws' | 'vosk' | 'parakeet' | 'piper';\n\n/** All speech credentials, resolved from config (or the central credential store). */\nexport interface VoiceCredentials {\n openaiKey: string;\n openrouterKey: string;\n azureKey: string;\n azureRegion: string;\n aws: AwsCreds;\n}\n\n/** Provider-specific voice ids (each provider names voices differently). */\nexport interface VoiceNames {\n openai: string; // alloy/echo/…\n azure: string; // e.g. de-DE-KatjaNeural\n aws: string; // e.g. Vicki\n piper: string; // e.g. de_DE-thorsten-medium\n openrouter: string; // depends on the model, e.g. Kore, george\n}\n\n/** Everything the factory needs to build any engine. */\nexport interface EngineContext {\n creds: VoiceCredentials;\n voices: VoiceNames;\n /** Optional second engine, used when the primary one fails ('' = none). */\n sttFallback?: SpeechProvider | '';\n ttsFallback?: SpeechProvider | '';\n /** Writable instance data dir (for the local engines' downloads). */\n dataDir: string;\n log: VoiceLogger;\n /** Local model overrides ('' → default per language). */\n voskModel: string;\n /** OpenAI STT model ('' → 'whisper-1'; e.g. 'gpt-4o-transcribe'). */\n sttModel: string;\n /**\n * OpenAI-compatible transcription server instead of OpenAI ('' = OpenAI), e.g. a local whisper container.\n * It gets `sttServerKey`, never the OpenAI key — that one is only for OpenAI.\n */\n sttBaseUrl?: string;\n /** Key for `sttBaseUrl` ('' = the server needs none). */\n sttServerKey?: string;\n /** OpenAI TTS model ('' → 'tts-1'; e.g. 'gpt-4o-mini-tts'). */\n ttsModel: string;\n /** OpenRouter models ('' → the defaults of openrouter.ts) */\n openrouterSttModel: string;\n openrouterTtsModel: string;\n /** Decoder for compressed speech (OpenRouter models that only return mp3); absent → those models fail */\n decodeAudio?: AudioDecoder;\n /** Longest text that is spoken, in characters; longer ones are cut at a sentence end. 0 = no limit, absent = 400. */\n ttsMaxChars?: number;\n /**\n * Language the satellites listen in (ISO-639-1). A voice set for one language (Polly 'Vicki') is only used for\n * it; an answer in another language gets the default voice of that language.\n */\n language?: string;\n /**\n * Table \"voice per language\" (ISO code → voice and/or model of the main TTS provider); absent = the voices above.\n * A model only for OpenAI and OpenRouter, the others have no choice.\n */\n voicesByLanguage?: Record<string, LanguageVoice>;\n /** Language the answering tier reported for exactly this text (pi-agent `language`); absent → by its letters. */\n reportedLanguage?: (text: string) => string | undefined;\n /** Instance of ioBroker.voice for the provider `parakeet`, e.g. 'voice.0'. */\n parakeetInstance?: string;\n /** Message bus to other instances (voice); absent → `parakeet` cannot be used. */\n sendMessage?: MessageSender;\n}\n\nfunction requireAzure(creds: VoiceCredentials): void {\n if (!creds.azureKey || !creds.azureRegion) {\n throw new Error('Azure speech needs a subscription key and region');\n }\n}\n\nfunction requireAws(creds: VoiceCredentials): void {\n if (!creds.aws.accessKeyId || !creds.aws.secretAccessKey || !creds.aws.region) {\n throw new Error('AWS speech needs an access key id, secret access key and region');\n }\n}\n\nfunction requireOpenAi(creds: VoiceCredentials): void {\n if (!creds.openaiKey) {\n throw new Error('OpenAI speech needs an API key');\n }\n}\n\nfunction requireOpenRouter(creds: VoiceCredentials): void {\n if (!creds.openrouterKey) {\n throw new Error('OpenRouter speech needs an API key');\n }\n}\n\nexport function createSttEngine(provider: SpeechProvider, ctx: EngineContext): SttEngine {\n const primary: NamedEngine<SttEngine> = { name: provider, engine: buildSttEngine(provider, ctx) };\n const fallback = ctx.sttFallback && ctx.sttFallback !== provider ? ctx.sttFallback : '';\n if (!fallback) {\n return primary.engine;\n }\n try {\n return new FallbackStt([primary, { name: fallback, engine: buildSttEngine(fallback, ctx) }], ctx.log);\n } catch (e) {\n ctx.log.warn(`Speech-to-text fallback '${fallback}' unavailable: ${(e as Error).message}`);\n return primary.engine;\n }\n}\n\nfunction buildSttEngine(provider: SpeechProvider, ctx: EngineContext): SttEngine {\n switch (provider) {\n case 'azure':\n requireAzure(ctx.creds);\n return new AzureStt(ctx.creds.azureKey, ctx.creds.azureRegion);\n case 'aws':\n requireAws(ctx.creds);\n return new AwsStt(ctx.creds.aws);\n case 'vosk':\n return new VoskStt(ctx.dataDir, ctx.voskModel, ctx.log);\n case 'parakeet':\n if (!ctx.sendMessage) {\n throw new Error('Parakeet speech recognition is not available here');\n }\n return new ParakeetStt((ctx.parakeetInstance || '').trim(), ctx.sendMessage);\n case 'openrouter':\n requireOpenRouter(ctx.creds);\n return new OpenRouterStt(ctx.creds.openrouterKey, ctx.openrouterSttModel);\n case 'piper':\n throw new Error('Piper is a text-to-speech engine, not speech-to-text');\n default:\n if (ctx.sttBaseUrl?.trim()) {\n return new OpenAiStt(ctx.sttServerKey || '', ctx.sttModel || undefined, ctx.sttBaseUrl);\n }\n requireOpenAi(ctx.creds);\n return new OpenAiStt(ctx.creds.openaiKey, ctx.sttModel || undefined);\n }\n}\n\nexport function createTtsEngine(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n // Outermost: every text is spoken in its own language — a German voice spells a Russian answer letter by letter\n return new LanguageTts(fallbackTts(provider, ctx), ctx.reportedLanguage, ctx.log);\n}\n\nfunction fallbackTts(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n // Each engine gets the shared behaviour (disk cache, length limit, SSML) and its own cache directory,\n // so a fallback engine's voice can never be served later while the primary one is healthy again.\n const primary: NamedEngine<TtsEngine> = { name: provider, engine: withLanguageVoices(provider, ctx) };\n const fallback = ctx.ttsFallback && ctx.ttsFallback !== provider ? ctx.ttsFallback : '';\n if (!fallback) {\n return primary.engine;\n }\n try {\n return new FallbackTts([primary, { name: fallback, engine: cachedTts(fallback, ctx) }], ctx.log);\n } catch (e) {\n // A fallback that cannot even be built (missing key, wrong provider) must not take the main one down.\n ctx.log.warn(`Text-to-speech fallback '${fallback}' unavailable: ${(e as Error).message}`);\n return primary.engine;\n }\n}\n\n/** Key of a provider in {@link VoiceNames}; the speech-to-text-only providers have no voice. */\nfunction voiceKey(provider: SpeechProvider): keyof VoiceNames | '' {\n return provider === 'vosk' || provider === 'parakeet' ? '' : provider;\n}\n\n/** Providers whose TTS model can be chosen. */\nfunction hasTtsModel(provider: SpeechProvider): boolean {\n return provider === 'openai' || provider === 'openrouter';\n}\n\n/**\n * The engine context of one row of the table \"voice per language\": its voice and model instead of the ones set above.\n * Another OpenRouter model without a voice of its own gets none — the voices belong to the model, the engine then\n * takes the first one of the model for the language.\n */\nfunction rowContext(\n provider: SpeechProvider,\n key: keyof VoiceNames,\n lang: string,\n row: LanguageVoice,\n ctx: EngineContext,\n): EngineContext {\n const model = hasTtsModel(provider) ? row.model : '';\n const otherModel =\n provider === 'openrouter' && !!model && model !== (ctx.openrouterTtsModel || DEFAULT_OPENROUTER_TTS_MODEL);\n const voice = row.voice || (otherModel ? '' : ctx.voices[key]);\n return {\n ...ctx,\n // the voice of a row is for its language (Polly names say nothing about it)\n language: lang,\n voices: { ...ctx.voices, [key]: voice },\n ttsModel: provider === 'openai' && model ? model : ctx.ttsModel,\n openrouterTtsModel: provider === 'openrouter' && model ? model : ctx.openrouterTtsModel,\n };\n}\n\n/**\n * The main provider with the table \"voice per language\": one engine per row with that voice and model. The table\n * names voices and models of the main provider, so the fallback provider does not get it.\n */\nfunction withLanguageVoices(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n const main = cachedTts(provider, ctx);\n const key = voiceKey(provider);\n const rows = Object.entries(ctx.voicesByLanguage || {});\n if (!key || !rows.length) {\n return main;\n }\n const byLanguage: Record<string, TtsEngine> = {};\n for (const [lang, row] of rows) {\n if (row.model && !hasTtsModel(provider)) {\n ctx.log.warn(`TTS model '${row.model}' for '${lang}' ignored: ${provider} has no model choice`);\n if (!row.voice) {\n continue;\n }\n }\n try {\n byLanguage[lang] = cachedTts(provider, rowContext(provider, key, lang, row, ctx));\n } catch (e) {\n ctx.log.warn(`Voice '${row.voice || row.model}' for '${lang}' unavailable: ${(e as Error).message}`);\n }\n }\n return new VoicePerLanguage(main, byLanguage);\n}\n\n/**\n * One provider binding plus the shared cache/length/SSML layer. One cache directory per provider+voice —\n * a voice change must not serve audio in the old voice.\n */\nfunction cachedTts(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n const voice =\n provider === 'azure'\n ? ctx.voices.azure\n : provider === 'aws'\n ? ctx.voices.aws\n : provider === 'piper'\n ? ctx.voices.piper\n : provider === 'openrouter'\n ? `${ctx.openrouterTtsModel || DEFAULT_OPENROUTER_TTS_MODEL}-${ctx.voices.openrouter}`\n : // the model too: another model must not serve the audio of the old one\n `${ctx.ttsModel ? `${ctx.ttsModel}-` : ''}${ctx.voices.openai}`;\n const dir = path.join(ctx.dataDir, 'ttscache', `${provider}-${(voice || 'default').replace(/[^\\w.-]/g, '_')}`);\n return new CachedTts(buildTtsEngine(provider, ctx), { dir, log: ctx.log, maxChars: ctx.ttsMaxChars });\n}\n\nfunction buildTtsEngine(provider: SpeechProvider, ctx: EngineContext): TtsEngine {\n switch (provider) {\n case 'azure':\n requireAzure(ctx.creds);\n return new AzureTts(ctx.creds.azureKey, ctx.creds.azureRegion, ctx.voices.azure);\n case 'aws':\n requireAws(ctx.creds);\n return new AwsTts(ctx.creds.aws, ctx.voices.aws, ctx.language);\n case 'piper':\n return new PiperTts(ctx.dataDir, ctx.voices.piper, ctx.log);\n case 'vosk':\n throw new Error('Vosk is a speech-to-text engine, not text-to-speech');\n case 'parakeet':\n throw new Error('Parakeet is a speech-to-text engine, not text-to-speech');\n case 'openrouter':\n requireOpenRouter(ctx.creds);\n return new OpenRouterTts(\n ctx.creds.openrouterKey,\n ctx.openrouterTtsModel,\n ctx.voices.openrouter,\n ctx.decodeAudio,\n );\n default:\n requireOpenAi(ctx.creds);\n return new OpenAiTts(\n ctx.creds.openaiKey,\n (ctx.voices.openai || 'alloy') as OpenAiVoice,\n ctx.ttsModel || undefined,\n );\n }\n}\n\n/** OpenAI TTS voices are a fixed set (no list API). */\nconst OPENAI_VOICES = ['alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'];\n\n/** List the available TTS voices for a provider (for the settings voice dropdown). */\nexport async function listVoices(provider: SpeechProvider, ctx: EngineContext, language: string): Promise<string[]> {\n switch (provider) {\n case 'azure':\n requireAzure(ctx.creds);\n return listAzureVoices(ctx.creds.azureKey, ctx.creds.azureRegion, isoToLocale(language));\n case 'aws':\n requireAws(ctx.creds);\n return listPollyVoices(ctx.creds.aws, isoToLocale(language));\n case 'piper':\n return listPiperVoices();\n case 'openrouter': {\n // public list, no key needed: the voices of the chosen model\n const model = ctx.openrouterTtsModel || DEFAULT_OPENROUTER_TTS_MODEL;\n const models = await listOpenRouterSpeechModels('speech');\n return voicesForLanguage(models.find(m => m.id === model)?.voices || [], language);\n }\n default:\n return OPENAI_VOICES;\n }\n}\n\n/** Suggested STT model names for the settings dropdown: the local Vosk catalogue, or the models of OpenRouter. */\nexport async function listSttModels(provider: SpeechProvider, language: string): Promise<string[]> {\n if (provider === 'openrouter') {\n return (await listOpenRouterSpeechModels('transcription')).map(m => m.id);\n }\n return provider === 'vosk' ? listVoskModels(language) : [];\n}\n\n/** OpenAI TTS models (no list API that tells speech models apart). */\nconst OPENAI_TTS_MODELS = ['tts-1', 'tts-1-hd', 'gpt-4o-mini-tts'];\n\n/** TTS model names for the settings dropdown; the other providers have no model choice. */\nexport async function listTtsModels(provider: SpeechProvider): Promise<string[]> {\n if (provider === 'openrouter') {\n return (await listOpenRouterSpeechModels('speech')).map(m => m.id);\n }\n return provider === 'openai' ? OPENAI_TTS_MODELS : [];\n}\n"]}
|
|
@@ -1462,7 +1462,11 @@ class EsphomeConnection {
|
|
|
1462
1462
|
* so we ask for one instead of assuming the write took.
|
|
1463
1463
|
*/
|
|
1464
1464
|
setWakeWords(ids) {
|
|
1465
|
-
|
|
1465
|
+
// Our own offers count as known even before the device echoed its list with them: every offer went out
|
|
1466
|
+
// with the configuration request sent when it was added, and the device handles messages in order, so
|
|
1467
|
+
// it has the offer when this SetConfiguration arrives (an install selects a word right after uploading).
|
|
1468
|
+
const offered = (this.opts.externalWakeWords?.() ?? []).map(w => w.id);
|
|
1469
|
+
const known = [...new Set([...(this.wakeWordConfig?.available.map(w => w.id) ?? []), ...offered])];
|
|
1466
1470
|
const wanted = [...new Set(ids.map(i => i.trim()).filter(Boolean))];
|
|
1467
1471
|
const unknown = wanted.filter(i => !known.includes(i));
|
|
1468
1472
|
if (unknown.length) {
|