iobroker.sayit 4.0.1 → 4.0.3

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 CHANGED
@@ -267,6 +267,11 @@ The following values for engines are possible:
267
267
  ### **WORK IN PROGRESS**
268
268
  -->
269
269
  ## Changelog
270
+ ### 4.0.3 (2024-07-11)
271
+ * (bluefox) Packages updated
272
+ * (bluefox) Corrected playing in vis
273
+ * (bluefox) Corrected blockly
274
+
270
275
  ### 4.0.1 (2024-05-25)
271
276
  * (bluefox) Packages updated
272
277
  * (neopholus) Using the pre-calculated duration of the mp3 to wait long enough even for longer announcements
package/io-package.json CHANGED
@@ -1,8 +1,21 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sayit",
4
- "version": "4.0.1",
4
+ "version": "4.0.3",
5
5
  "news": {
6
+ "4.0.3": {
7
+ "en": "Packages updated\nCorrected playing in vis\nCorrected blockly",
8
+ "de": "Pakete aktualisiert\nKorrigiertes Spielen in Vis\nBlockiert korrigiert",
9
+ "ru": "Обновленные пакеты\nИсправленная игра в vis\nИсправлено блокно",
10
+ "pt": "Pacotes atualizados\nJogo correto em vis\nCorrigido em bloco",
11
+ "nl": "Pakketten bijgewerkt\nGecorrigeerd spelen in vis\nBloksgewijs gecorrigeerd",
12
+ "fr": "Mise à jour des paquets\nCorrigé jouer dans vis\nCorrigé en bloc",
13
+ "it": "Pacchetti aggiornati\nCorretto giocare in vis\nCorretto in blocco",
14
+ "es": "Paquetes actualizados\nCorregido jugando en vis\nCorregido bloqueado",
15
+ "pl": "Aktualizacja pakietów\nPoprawione gry w vis\nPoprawione blokowane",
16
+ "uk": "Пакети оновлені\nПравильна гра в віках\nВиправлено блоклі",
17
+ "zh-cn": "更新软件包\n已校正播放相对\n块状修正"
18
+ },
6
19
  "4.0.1": {
7
20
  "en": "Packages updated\nUsing the pre-calculated duration of the mp3 to wait long enough even for longer announcements",
8
21
  "de": "Pakete aktualisiert\nMit der vorkalkulierten Dauer des mp3 lange genug warten, auch für längere Ankündigungen",
@@ -80,19 +93,6 @@
80
93
  "pl": "Wsparcie Coqui TTS\nNazwy wszystkich cech konfiguracji",
81
94
  "uk": "Додано підтримку Coqui TTS\nПерейменувати всі атрибути конфігурації",
82
95
  "zh-cn": "增加对共同采购技术的支持\n重新命名所有组合的属性"
83
- },
84
- "2.0.0": {
85
- "en": "Adapter was completely rewritten with async/await\nCould be buggy",
86
- "de": "Adapter wurde komplett neu geschrieben mit async/await\nKönnte Buggy sein",
87
- "ru": "Адаптер был полностью переписан с async/await\nМожет быть багги",
88
- "pt": "Adapter foi completamente reescrito com async/await\nPode ser buggy",
89
- "nl": "Adapter was volledig herschreven met async/a wacht\nKan insecten zijn",
90
- "fr": "Adaptateur a été complètement réécrit avec async/await\nÇa pourrait être un buggy",
91
- "it": "L'adattatore è stato completamente riscritto con asinc/await\nPotrebbe essere buggy",
92
- "es": "Adaptador fue completamente reescrito con async/await\nPodría ser un buggy",
93
- "pl": "Adapter został w całości przepisany z asynchronem/await/Adapter\nCould be buggy",
94
- "uk": "Перехідник повністю переписався з асинхроном/відповіддю\nПомилки",
95
- "zh-cn": "道歉完全用阿森克/瓦伊特写。\n走私"
96
96
  }
97
97
  },
98
98
  "title": "Text to speech",
@@ -137,7 +137,6 @@
137
137
  "supportStopInstance": true,
138
138
  "stopBeforeUpdate": true,
139
139
  "icon": "sayit.png",
140
- "materialize": true,
141
140
  "adminUI": {
142
141
  "config": "json"
143
142
  },
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
- const path = require('path');
3
- const fs = require('fs');
2
+ const path = require('node:path');
3
+ const fs = require('node:fs');
4
4
  let jsftp;
5
5
  let os;
6
6
  let cp;
@@ -19,7 +19,7 @@ class Speech2Device {
19
19
  }
20
20
 
21
21
  async exec(cmd, args, cwd) {
22
- cp = cp || require('child_process');
22
+ cp = cp || require('node:child_process');
23
23
  return new Promise((resolve, reject) => {
24
24
  try {
25
25
  const _cmd = `${cmd}${args && args.length ? ` ${args.join(' ')}` : ''}`;
@@ -48,7 +48,7 @@ class Speech2Device {
48
48
  }
49
49
 
50
50
  async spawn(cmd, args, ignoreErrorCode) {
51
- cp = cp || require('child_process');
51
+ cp = cp || require('node:child_process');
52
52
  return new Promise((resolve, reject) => {
53
53
  try {
54
54
  this.adapter.log.debug(`Execute ${cmd} ${args.join(' ')}`);
@@ -112,16 +112,15 @@ class Speech2Device {
112
112
  const result = await this.uploadToStates(text);
113
113
 
114
114
  const browserInstance = (testOptions && testOptions.browserInstance) || this.adapter.config.browserInstance;
115
- const browserVis = (testOptions && testOptions.browserVis) || this.adapter.config.browserVis;
115
+ const browserVis = testOptions?.browserVis === undefined ? this.adapter.config.browserVis : testOptions.browserVis;
116
116
 
117
117
  // check if vis.0.control.command exists
118
118
  if (!browserVis || browserVis === 1 || browserVis === '1') {
119
119
  try {
120
120
  if (this.vis1exist === null) {
121
- this.vis1exist = !!(await this.adapter.getObjectAsync('vis.0.control.command'));
121
+ this.vis1exist = !!(await this.adapter.getForeignObjectAsync('vis.0.control.command'));
122
122
  if (!this.vis1exist) {
123
123
  this.adapter.log.error('Cannot control browser via vis1, because vis.0.* objects found');
124
- return;
125
124
  }
126
125
  }
127
126
  if (this.vis1exist) {
@@ -138,7 +137,7 @@ class Speech2Device {
138
137
  if (!browserVis || browserVis === 2 || browserVis === '2') {
139
138
  try {
140
139
  if (this.vis2exist === null) {
141
- this.vis2exist = !!(await this.adapter.getObjectAsync('vis-2.0.control.command'));
140
+ this.vis2exist = !!(await this.adapter.getForeignObjectAsync('vis-2.0.control.command'));
142
141
  if (!this.vis2exist) {
143
142
  this.adapter.log.error('Cannot control browser via vis1, because vis-2.0.* objects found');
144
143
  return;
@@ -439,7 +438,7 @@ class Speech2Device {
439
438
  const ftpUser = (testOptions && testOptions.ftpUser) || this.adapter.config.ftpUser;
440
439
  const ftpPassword = (testOptions && testOptions.ftpPassword) || this.adapter.config.ftpPassword;
441
440
 
442
- // Copy mp3 file to android device to play it later with MediaPlayer
441
+ // Copy mp3 file to an android device to play it later with MediaPlayer
443
442
  if (ftpPort && mp24Server) {
444
443
  jsftp = jsftp || require('jsftp');
445
444
  axios = axios || require('axios');
@@ -490,8 +489,8 @@ class Speech2Device {
490
489
  }
491
490
 
492
491
  async sayItSystem(text, language, volume, duration, testOptions) {
493
- os = os || require('os');
494
- cp = cp || require('child_process');
492
+ os = os || require('node:os');
493
+ cp = cp || require('node:child_process');
495
494
 
496
495
  const result = await this.uploadToStates(text);
497
496
  const systemCommand = (testOptions && testOptions.systemCommand) || this.adapter.config.systemCommand;
@@ -565,7 +564,7 @@ class Speech2Device {
565
564
  return this.sayItSystem(text, language, volume, duration, testOptions);
566
565
  }
567
566
 
568
- os = os || require('os');
567
+ os = os || require('node:os');
569
568
 
570
569
  // Call windows own text 2 speech
571
570
  const p = os.platform();
@@ -604,8 +603,8 @@ class Speech2Device {
604
603
  if (level === this.options.sayLastVolume) {
605
604
  return;
606
605
  }
607
- os = os || require('os');
608
- cp = cp || require('child_process');
606
+ os = os || require('node:os');
607
+ cp = cp || require('node:child_process');
609
608
 
610
609
  await this.adapter.setStateAsync('tts.volume', level, true);
611
610
 
@@ -644,27 +643,36 @@ class Speech2Device {
644
643
  type = testOptions ? testOptions.type || type : type;
645
644
  if (type === 'browser') {
646
645
  return await this.sayItBrowser(text, language, volume, duration, testOptions);
647
- } else if (type === 'mp24ftp') {
646
+ }
647
+ if (type === 'mp24ftp') {
648
648
  return await this.sayItMP24ftp(text, language, volume, duration, testOptions);
649
- } else if (type === 'mp24') {
649
+ }
650
+ if (type === 'mp24') {
650
651
  return await this.sayItMP24(text, language, volume, duration, testOptions);
651
- } else if (type === 'system') {
652
+ }
653
+ if (type === 'system') {
652
654
  return await this.sayItSystem(text, language, volume, duration, testOptions);
653
- } else if (type === 'windows') {
655
+ }
656
+ if (type === 'windows') {
654
657
  return await this.sayItWindows(text, language, volume, duration, testOptions);
655
- } else if (type === 'sonos') {
658
+ }
659
+ if (type === 'sonos') {
656
660
  return await this.sayItSonos(text, language, volume, duration, testOptions);
657
- } else if (type === 'heos') {
661
+ }
662
+ if (type === 'heos') {
658
663
  return await this.sayItHeos(text, language, volume, duration, testOptions);
659
- } else if (type === 'chromecast') {
664
+ }
665
+ if (type === 'chromecast') {
660
666
  return await this.sayItChromecast(text, language, volume, duration, testOptions);
661
- } else if (type === 'mpd') {
667
+ }
668
+ if (type === 'mpd') {
662
669
  return await this.sayItMpd(text, language, volume, duration, testOptions);
663
- } else if (type === 'googleHome') {
670
+ }
671
+ if (type === 'googleHome') {
664
672
  return await this.sayItGoogleHome(text, language, volume, duration, testOptions);
665
- } else {
666
- this.adapter.log.error(`Unknown play type: ${type}`);
667
673
  }
674
+
675
+ this.adapter.log.error(`Unknown play type: ${type}`);
668
676
  }
669
677
 
670
678
  static sayItIsPlayFile = Speech2Device.isPlayFile;
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
- const fs = require('fs');
2
+ const fs = require('node:fs');
3
3
  const mp3Duration = require('mp3-duration');
4
4
  const engines = require('../admin/engines.js');
5
5
  const sayitEngines = engines.sayitEngines;
6
- const { URLSearchParams } = require('url');
6
+ const { URLSearchParams } = require('node:url');
7
7
  const { PollyClient, SynthesizeSpeechCommand } = require('@aws-sdk/client-polly');
8
8
 
9
9
  let cp;
@@ -68,7 +68,7 @@ class Text2Speech {
68
68
  }
69
69
 
70
70
  async exec(cmd, args, cwd) {
71
- cp = cp || require('child_process');
71
+ cp = cp || require('node:child_process');
72
72
  return new Promise((resolve, reject) => {
73
73
  try {
74
74
  const ls = cp.exec(`${cmd}${args && args.length ? ` ${args.join(' ')}` : ''}`, {cwd}, code => {
package/main.js CHANGED
@@ -2,13 +2,13 @@
2
2
  /* jshint strict: false */
3
3
  /* jslint node: true */
4
4
  'use strict';
5
+ const fs = require('node:fs');
6
+ const path = require('node:path');
5
7
  const utils = require('@iobroker/adapter-core'); // Get common adapter utils
6
8
  const engines = require('./admin/engines.js');
7
9
  const Text2Speech = require('./lib/text2speech');
8
10
  const Speech2Device = require('./lib/speech2device');
9
11
  const adapterName = require('./package.json').name.split('.').pop();
10
- const fs = require('fs');
11
- const path = require('path');
12
12
 
13
13
  const sayitOptions = engines.sayitOptions;
14
14
 
@@ -102,7 +102,21 @@ function startAdapter(options) {
102
102
 
103
103
  function processMessage(obj) {
104
104
  if (obj) {
105
- if (obj.command === 'stopInstance') {
105
+ if (obj.command === 'say') {
106
+ const text = obj.message.text;
107
+ const language = obj.message?.language;
108
+ const volume = obj.message?.volume;
109
+
110
+ if (obj.callback) {
111
+ const opts = {...obj.message};
112
+ opts.callback = error => {
113
+ adapter.sendTo(obj.from, obj.command, {error, result: error ? undefined : 'Ok'}, obj.callback);
114
+ };
115
+ addToQueue(text, language, volume, null, opts);
116
+ } else {
117
+ addToQueue(text, language, volume);
118
+ }
119
+ } else if (obj.command === 'stopInstance') {
106
120
  stop(false, () =>
107
121
  obj.callback && adapter.sendTo(obj.from, obj.command, null, obj.callback));
108
122
  } else if (obj.callback && obj.command === 'browseGoogleHome') {
@@ -128,7 +142,7 @@ function processMessage(obj) {
128
142
 
129
143
  browser.start();
130
144
  } catch (e) {
131
- adapter.log.error(e);
145
+ adapter.log.debug(`Cannot browse mdns: ${e}`);
132
146
  adapter.sendTo(obj.from, obj.command, null, obj.callback);
133
147
  }
134
148
  } else if (obj.callback && obj.command === 'browseChromecast') {
@@ -175,7 +189,7 @@ function processMessage(obj) {
175
189
  adapter.sendTo(obj.from, obj.command, list, obj.callback);
176
190
  });
177
191
  } else if (obj.callback && obj.command === 'test') {
178
- const language = (obj.message.engine || adapter.config.engine).substring(0, 2);
192
+ const language = (obj.message?.engine || adapter.config.engine).substring(0, 2);
179
193
  let text = 'Hello';
180
194
  if (language === 'de') {
181
195
  text = 'Hallo';
@@ -255,7 +269,7 @@ function addToQueue(text, language, volume, onlyCache, testOptions) {
255
269
  // Extract language from "en;volume;Text to say"
256
270
  if (text.includes(';')) {
257
271
  const arr = text.split(';', 3);
258
- // If language;text or volume;text
272
+ // If "language;text" or "volume;text"
259
273
  if (arr.length === 2) {
260
274
  // If number
261
275
  if (parseInt(arr[0]).toString() === arr[0].toString()) {
@@ -325,7 +339,7 @@ function addToQueue(text, language, volume, onlyCache, testOptions) {
325
339
  }
326
340
 
327
341
  function getCachedFileName(dir, text, fileExt) {
328
- crypto = crypto || require('crypto');
342
+ crypto = crypto || require('node:crypto');
329
343
  return path.normalize(path.join(dir, `${crypto.createHash('md5').update(text).digest('hex')}.${fileExt}`));
330
344
  }
331
345
 
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "iobroker.sayit",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Text to speech interface for ioBroker.",
5
5
  "author": {
6
6
  "name": "bluefox",
7
7
  "email": "dogafox@gmail.com"
8
8
  },
9
9
  "engines": {
10
- "node": ">=14.0.0"
10
+ "node": ">=18.0.0"
11
11
  },
12
12
  "contributors": [
13
13
  {
@@ -40,19 +40,19 @@
40
40
  },
41
41
  "dependencies": {
42
42
  "jsftp": "^2.1.3",
43
- "@aws-sdk/client-polly": "^3.583.0",
44
- "@iobroker/adapter-core": "^3.1.4",
43
+ "@aws-sdk/client-polly": "^3.614.0",
44
+ "@iobroker/adapter-core": "^3.1.6",
45
45
  "google-tts-api": "^2.0.2",
46
46
  "axios": "^1.7.2",
47
47
  "mp3-duration": "^1.1.0"
48
48
  },
49
49
  "devDependencies": {
50
- "@alcalzone/release-script": "^3.7.0",
51
- "@alcalzone/release-script-plugin-iobroker": "^3.7.0",
50
+ "@alcalzone/release-script": "^3.7.3",
51
+ "@alcalzone/release-script-plugin-iobroker": "^3.7.2",
52
52
  "@alcalzone/release-script-plugin-license": "^3.7.0",
53
- "@iobroker/adapter-dev": "^1.2.0",
53
+ "@iobroker/adapter-dev": "^1.3.0",
54
54
  "@iobroker/legacy-testing": "^1.0.12",
55
- "mocha": "^10.4.0",
55
+ "mocha": "^10.6.0",
56
56
  "chai": "^4.4.1"
57
57
  },
58
58
  "bugs": {
@@ -77,7 +77,8 @@
77
77
  "release-patch": "release-script patch --yes",
78
78
  "release-minor": "release-script minor --yes",
79
79
  "release-major": "release-script major --yes",
80
- "translate": "translate-adapter"
80
+ "translate": "translate-adapter",
81
+ "update-packages": "ncu --upgrade"
81
82
  },
82
83
  "license": "MIT",
83
84
  "readmeFilename": "README.md"