iobroker.assistant 1.6.0 → 1.8.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 +8 -0
- package/admin/i18n/de.json +4 -1
- package/admin/i18n/en.json +4 -1
- package/admin/i18n/es.json +4 -1
- package/admin/i18n/fr.json +4 -1
- package/admin/i18n/it.json +4 -1
- package/admin/i18n/nl.json +4 -1
- package/admin/i18n/pl.json +4 -1
- package/admin/i18n/pt.json +4 -1
- package/admin/i18n/ru.json +4 -1
- package/admin/i18n/uk.json +4 -1
- package/admin/i18n/zh-cn.json +4 -1
- package/admin/jsonConfig.json +16 -0
- package/build/lib/piAgent.js +16 -0
- package/build/lib/piAgent.js.map +1 -1
- package/build/lib/voice/aws.js +9 -2
- package/build/lib/voice/aws.js.map +1 -1
- package/build/lib/voice/azure.js +6 -2
- package/build/lib/voice/azure.js.map +1 -1
- package/build/lib/voice/engines.js +34 -2
- package/build/lib/voice/engines.js.map +1 -1
- package/build/lib/voice/openrouter.js +5 -3
- package/build/lib/voice/openrouter.js.map +1 -1
- package/build/lib/voice/piper.js +6 -1
- package/build/lib/voice/piper.js.map +1 -1
- package/build/lib/voice/speechLanguage.js +306 -0
- package/build/lib/voice/speechLanguage.js.map +1 -0
- package/build/main.js +74 -19
- package/build/main.js.map +1 -1
- package/io-package.json +72 -29
- package/package.json +3 -2
package/build/main.js
CHANGED
|
@@ -76,6 +76,7 @@ const ttsCache_1 = require("./lib/voice/ttsCache");
|
|
|
76
76
|
const captures_1 = require("./lib/voice/captures");
|
|
77
77
|
const ffmpegStatic_1 = require("./lib/voice/ffmpegStatic");
|
|
78
78
|
const piAgent_1 = require("./lib/piAgent");
|
|
79
|
+
const speechLanguage_1 = require("./lib/voice/speechLanguage");
|
|
79
80
|
const installer_1 = require("./lib/installer");
|
|
80
81
|
const media_1 = require("./lib/media");
|
|
81
82
|
const systemAi_1 = require("./lib/systemAi");
|
|
@@ -143,6 +144,7 @@ const VOICE_FORM_FIELDS = [
|
|
|
143
144
|
'awsCredentialId',
|
|
144
145
|
'awsVoice',
|
|
145
146
|
'piperVoice',
|
|
147
|
+
'ttsVoices',
|
|
146
148
|
];
|
|
147
149
|
/** Of those, the protected ones: the browser never gets them, so an empty value there means "keep the saved one" */
|
|
148
150
|
const VOICE_FORM_SECRETS = [
|
|
@@ -757,6 +759,9 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
757
759
|
openrouterTtsModel: (cfg.openrouterTtsModel || '').trim(),
|
|
758
760
|
decodeAudio: audio => this.decodeAudioBufferToPcm(audio),
|
|
759
761
|
ttsMaxChars: (0, ttsCache_1.parseTtsMaxChars)(cfg.ttsMaxChars),
|
|
762
|
+
language: String(cfg.voiceLanguage || this.language || ''),
|
|
763
|
+
voicesByLanguage: (0, speechLanguage_1.parseVoiceTable)(cfg.ttsVoices),
|
|
764
|
+
reportedLanguage: text => this.reportedLanguage(text),
|
|
760
765
|
parakeetInstance: (cfg.parakeetInstance || '').trim().replace(/^system\.adapter\./, ''),
|
|
761
766
|
sendMessage: (instance, command, message) => this.askInstance(instance, command, message, PARAKEET_TIMEOUT_MS),
|
|
762
767
|
};
|
|
@@ -3418,9 +3423,12 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
3418
3423
|
attachments() {
|
|
3419
3424
|
return this.requestOrigin.getStore()?.attachments ?? NO_ATTACHMENTS;
|
|
3420
3425
|
}
|
|
3421
|
-
/**
|
|
3426
|
+
/**
|
|
3427
|
+
* Language of fixed replies: the language the request being answered was asked in, else the voice language, else
|
|
3428
|
+
* the system language.
|
|
3429
|
+
*/
|
|
3422
3430
|
answerLanguage() {
|
|
3423
|
-
return String(this.config.voiceLanguage || this.language || 'en');
|
|
3431
|
+
return this.requestOrigin.getStore()?.language || String(this.config.voiceLanguage || this.language || 'en');
|
|
3424
3432
|
}
|
|
3425
3433
|
/**
|
|
3426
3434
|
* Speech recognition for an `ask` that carries a recording instead of text. `audio` is base64; `format` says what
|
|
@@ -3485,10 +3493,19 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
3485
3493
|
const satellite = fromSatellite ? this.knownSatelliteId(origin.satellite || source, origin.room || '') : '';
|
|
3486
3494
|
// The journal shows "[picture] What is in this picture?", like the conversation history
|
|
3487
3495
|
const shown = (0, media_1.historyText)(question, attachments.images.length, !!attachments.video);
|
|
3488
|
-
|
|
3496
|
+
const configured = String(this.config.voiceLanguage || this.language || 'en');
|
|
3497
|
+
// "скажи, сколько сейчас времени" on a German satellite: the time comes in Russian
|
|
3498
|
+
const language = (0, speechLanguage_1.questionLanguage)(question, configured);
|
|
3499
|
+
return this.requestOrigin.run({ source, room: origin.room || '', voice, satellite, attachments, language }, () => this.journal
|
|
3489
3500
|
? this.journal.run(shown, source, origin, () => {
|
|
3490
3501
|
this.traceSpeechInput(question, origin);
|
|
3491
3502
|
this.traceAttachments(attachments);
|
|
3503
|
+
if (language !== configured) {
|
|
3504
|
+
this.journal?.step({
|
|
3505
|
+
stage: 'request',
|
|
3506
|
+
title: `Question in '${language}', not '${configured}': fixed answers in '${language}'`,
|
|
3507
|
+
});
|
|
3508
|
+
}
|
|
3492
3509
|
return this.answerTracked(question, source);
|
|
3493
3510
|
})
|
|
3494
3511
|
: this.answerTracked(question, source));
|
|
@@ -3572,6 +3589,13 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
3572
3589
|
result = this.doneText();
|
|
3573
3590
|
}
|
|
3574
3591
|
}
|
|
3592
|
+
// An answer to a question in another language than the satellite's: its voice is told by this (an English
|
|
3593
|
+
// answer on a German satellite has the same letters, see LanguageTts)
|
|
3594
|
+
const language = this.answerLanguage();
|
|
3595
|
+
if (result &&
|
|
3596
|
+
(0, speechLanguage_1.baseLanguage)(language) !== (0, speechLanguage_1.baseLanguage)(String(this.config.voiceLanguage || this.language || 'en'))) {
|
|
3597
|
+
this.answerLanguages.remember(result, language);
|
|
3598
|
+
}
|
|
3575
3599
|
this.journal?.step({
|
|
3576
3600
|
stage: 'answer',
|
|
3577
3601
|
title: toned
|
|
@@ -3629,15 +3653,24 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
3629
3653
|
return '';
|
|
3630
3654
|
}
|
|
3631
3655
|
const limit = (0, ttsCache_1.parseTtsMaxChars)(this.config.ttsMaxChars) ?? ttsCache_1.MAX_TTS_CHARS;
|
|
3632
|
-
return (0, ttsCache_1.spokenLengthHint)(limit,
|
|
3656
|
+
return (0, ttsCache_1.spokenLengthHint)(limit, this.answerLanguage());
|
|
3633
3657
|
}
|
|
3634
3658
|
/** What [[DONE]] says where no beep can be played */
|
|
3635
3659
|
doneText() {
|
|
3636
|
-
const lang =
|
|
3660
|
+
const lang = this.answerLanguage();
|
|
3637
3661
|
return lang === 'ru' ? 'Готово.' : lang === 'de' ? 'Erledigt.' : 'Done.';
|
|
3638
3662
|
}
|
|
3639
3663
|
/** Per source: whether its last {@link answer} asked the user something (LLM-signalled via [[LISTEN]]). */
|
|
3640
3664
|
followUps = new Map();
|
|
3665
|
+
/**
|
|
3666
|
+
* The language the answering tier reported for exactly this answer text (pi-agent ≥ 0.10.1 `language`). The
|
|
3667
|
+
* transports hand the TTS only the text, so the TTS looks the language up by it.
|
|
3668
|
+
*/
|
|
3669
|
+
reportedLanguage(text) {
|
|
3670
|
+
return this.piAgent?.languageOf(text) || this.answerLanguages.languageOf(text) || undefined;
|
|
3671
|
+
}
|
|
3672
|
+
/** Answers given in the language of a question other than the configured one (see {@link answerTracked}). */
|
|
3673
|
+
answerLanguages = new speechLanguage_1.AnswerLanguages();
|
|
3641
3674
|
/** Per source: when the cloud model last asked back about a script (see {@link cloudOnlyReason}). */
|
|
3642
3675
|
scriptTopics = new Map();
|
|
3643
3676
|
/**
|
|
@@ -3733,7 +3766,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
3733
3766
|
* LLM. Localized (de/en/ru) spoken-style reply; uses the host's local timezone via {@link Intl}.
|
|
3734
3767
|
*/
|
|
3735
3768
|
executeTimeIntent(intent) {
|
|
3736
|
-
const lang =
|
|
3769
|
+
const lang = this.answerLanguage();
|
|
3737
3770
|
const locale = lang === 'de' ? 'de-DE' : lang === 'ru' ? 'ru-RU' : 'en-GB';
|
|
3738
3771
|
const now = new Date();
|
|
3739
3772
|
if (intent.action === 'dateQuery') {
|
|
@@ -3832,7 +3865,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
3832
3865
|
this.log.info(`Ring stopped by voice (${n} session(s)).`);
|
|
3833
3866
|
this.journal?.note({ tier: 'stop' });
|
|
3834
3867
|
this.journal?.step({ stage: 'stop', title: `Stop word: silenced ${n} ringing timer/alarm(s)` });
|
|
3835
|
-
const lang =
|
|
3868
|
+
const lang = this.answerLanguage();
|
|
3836
3869
|
return lang === 'ru' ? 'Хорошо.' : lang === 'de' ? 'Ok.' : 'Okay.';
|
|
3837
3870
|
}
|
|
3838
3871
|
// An open question from `askUser` claims the next utterance of that source as its answer — before
|
|
@@ -4033,7 +4066,25 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
4033
4066
|
// task) — its `tts` state says it there.
|
|
4034
4067
|
const satellite = this.requestOrigin.getStore()?.satellite || '';
|
|
4035
4068
|
const tts = satellite ? `${this.namespace}.satellites.${satellite}.tts` : '';
|
|
4036
|
-
|
|
4069
|
+
const answer = await harness.ask({
|
|
4070
|
+
text,
|
|
4071
|
+
conversation: source,
|
|
4072
|
+
instructions,
|
|
4073
|
+
language,
|
|
4074
|
+
images,
|
|
4075
|
+
satellite,
|
|
4076
|
+
tts,
|
|
4077
|
+
});
|
|
4078
|
+
const spokenIn = harness.languageOf(answer);
|
|
4079
|
+
if (spokenIn) {
|
|
4080
|
+
// the voice of the satellite may not speak it: the TTS takes a voice of this language
|
|
4081
|
+
this.journal?.step({
|
|
4082
|
+
stage: 'cloud',
|
|
4083
|
+
title: `${harness.instance} answered in '${spokenIn}'`,
|
|
4084
|
+
data: { language: spokenIn },
|
|
4085
|
+
});
|
|
4086
|
+
}
|
|
4087
|
+
return answer;
|
|
4037
4088
|
}
|
|
4038
4089
|
catch (e) {
|
|
4039
4090
|
if (localFallback) {
|
|
@@ -4103,7 +4154,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
4103
4154
|
}
|
|
4104
4155
|
/** Reply when nothing local understood the request and there is no cloud LLM (provider "none"). */
|
|
4105
4156
|
localOnlyFallback() {
|
|
4106
|
-
const lang =
|
|
4157
|
+
const lang = this.answerLanguage();
|
|
4107
4158
|
if (lang === 'ru') {
|
|
4108
4159
|
return 'Извини, этого я не поняла. Без облачной языковой модели я понимаю только простые команды для устройств, таймеры и будильники.';
|
|
4109
4160
|
}
|
|
@@ -4865,7 +4916,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
4865
4916
|
if (!device || !intent.stateId) {
|
|
4866
4917
|
throw new Error('deferred intent without a device');
|
|
4867
4918
|
}
|
|
4868
|
-
const lang =
|
|
4919
|
+
const lang = this.answerLanguage();
|
|
4869
4920
|
const pick = (rus, ger, eng) => lang === 'ru' ? rus : lang === 'de' ? ger : eng;
|
|
4870
4921
|
const room = intent.room || device.room;
|
|
4871
4922
|
const where = room ? ` (${room})` : '';
|
|
@@ -5029,7 +5080,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5029
5080
|
if (!res.report) {
|
|
5030
5081
|
throw new Error(res.error || 'no weather report');
|
|
5031
5082
|
}
|
|
5032
|
-
const lang =
|
|
5083
|
+
const lang = this.answerLanguage();
|
|
5033
5084
|
const text = (0, weather_1.buildWeatherAnswer)(res.report, lang, intent.when);
|
|
5034
5085
|
if (!text) {
|
|
5035
5086
|
throw new Error(`the weather report has no data for '${intent.when || 'now'}'`);
|
|
@@ -5042,7 +5093,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5042
5093
|
* of an ESPHome device, the `volume` message of a UDP satellite.
|
|
5043
5094
|
*/
|
|
5044
5095
|
async executeVolumeIntent(intent, source) {
|
|
5045
|
-
const lang =
|
|
5096
|
+
const lang = this.answerLanguage();
|
|
5046
5097
|
const satId = intent.room ? this.resolveSatelliteId(intent.room) : this.announceTargetForSource(source);
|
|
5047
5098
|
const absolute = typeof intent.value === 'number' ? intent.value : null;
|
|
5048
5099
|
const delta = intent.delta || 0;
|
|
@@ -5105,7 +5156,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5105
5156
|
}
|
|
5106
5157
|
/** Localized "this part did not work" sentence for a failed part of a combined command. */
|
|
5107
5158
|
nluFailureText(intent) {
|
|
5108
|
-
const lang =
|
|
5159
|
+
const lang = this.answerLanguage();
|
|
5109
5160
|
const what = intent.device?.name ? ` (${intent.device.name})` : '';
|
|
5110
5161
|
return lang === 'ru'
|
|
5111
5162
|
? `Одну команду${what} выполнить не удалось.`
|
|
@@ -5299,7 +5350,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5299
5350
|
return '';
|
|
5300
5351
|
}
|
|
5301
5352
|
// Respond in the assistant's interaction language (voice language, else system).
|
|
5302
|
-
const lang =
|
|
5353
|
+
const lang = this.answerLanguage();
|
|
5303
5354
|
const ru = lang === 'ru';
|
|
5304
5355
|
const de = lang === 'de';
|
|
5305
5356
|
const pick = (rus, ger, eng) => (ru ? rus : de ? ger : eng);
|
|
@@ -5368,7 +5419,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5368
5419
|
if (!mcp) {
|
|
5369
5420
|
throw new Error('mcp not ready');
|
|
5370
5421
|
}
|
|
5371
|
-
const lang =
|
|
5422
|
+
const lang = this.answerLanguage();
|
|
5372
5423
|
const ru = lang === 'ru';
|
|
5373
5424
|
const de = lang === 'de';
|
|
5374
5425
|
const pick = (rus, ger, eng) => (ru ? rus : de ? ger : eng);
|
|
@@ -5415,7 +5466,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5415
5466
|
if (!mcp) {
|
|
5416
5467
|
throw new Error('mcp not ready');
|
|
5417
5468
|
}
|
|
5418
|
-
const lang =
|
|
5469
|
+
const lang = this.answerLanguage();
|
|
5419
5470
|
const ru = lang === 'ru';
|
|
5420
5471
|
const de = lang === 'de';
|
|
5421
5472
|
const pick = (rus, ger, eng) => (ru ? rus : de ? ger : eng);
|
|
@@ -5878,7 +5929,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
5878
5929
|
if (!mgr) {
|
|
5879
5930
|
return '';
|
|
5880
5931
|
}
|
|
5881
|
-
const lang =
|
|
5932
|
+
const lang = this.answerLanguage();
|
|
5882
5933
|
const ru = lang === 'ru';
|
|
5883
5934
|
const de = lang === 'de';
|
|
5884
5935
|
const pick = (rus, ger, eng) => (ru ? rus : de ? ger : eng);
|
|
@@ -6147,7 +6198,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
6147
6198
|
if (!mgr) {
|
|
6148
6199
|
return '';
|
|
6149
6200
|
}
|
|
6150
|
-
const lang =
|
|
6201
|
+
const lang = this.answerLanguage();
|
|
6151
6202
|
const ru = lang === 'ru';
|
|
6152
6203
|
const de = lang === 'de';
|
|
6153
6204
|
const pick = (rus, ger, eng) => (ru ? rus : de ? ger : eng);
|
|
@@ -6410,7 +6461,7 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
6410
6461
|
* hear me". An already running TV is answered only after the player acknowledged the command.
|
|
6411
6462
|
*/
|
|
6412
6463
|
async playYouTube(query, kind, playerName) {
|
|
6413
|
-
const lang =
|
|
6464
|
+
const lang = this.answerLanguage();
|
|
6414
6465
|
const player = this.youtubePlayerFor(playerName);
|
|
6415
6466
|
if (!player) {
|
|
6416
6467
|
const names = this.youtubePlayers.map(p => p.name).join(', ');
|
|
@@ -7632,6 +7683,10 @@ class Assistant extends adapter_core_1.Adapter {
|
|
|
7632
7683
|
const cfg = { ...this.config, sttFallback: '', ttsFallback: '' };
|
|
7633
7684
|
for (const key of VOICE_FORM_FIELDS) {
|
|
7634
7685
|
const value = form[key];
|
|
7686
|
+
if (Array.isArray(value)) {
|
|
7687
|
+
cfg[key] = value; // the table "voice per language"
|
|
7688
|
+
continue;
|
|
7689
|
+
}
|
|
7635
7690
|
if (typeof value !== 'string' || (VOICE_FORM_SECRETS.includes(key) && !value.trim())) {
|
|
7636
7691
|
continue;
|
|
7637
7692
|
}
|