iobroker.sayit 4.0.3 → 4.0.5

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,10 +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)
270
+ ### 4.0.5 (2024-07-12)
271
271
  * (bluefox) Packages updated
272
272
  * (bluefox) Corrected playing in vis
273
273
  * (bluefox) Corrected blockly
274
+ * (bluefox) Corrected upload of files
274
275
 
275
276
  ### 4.0.1 (2024-05-25)
276
277
  * (bluefox) Packages updated
package/io-package.json CHANGED
@@ -1,20 +1,20 @@
1
1
  {
2
2
  "common": {
3
3
  "name": "sayit",
4
- "version": "4.0.3",
4
+ "version": "4.0.5",
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块状修正"
6
+ "4.0.5": {
7
+ "en": "Packages updated\nCorrected playing in vis\nCorrected blockly\nCorrected upload of files",
8
+ "de": "Pakete aktualisiert\nKorrigiertes Spielen in Vis\nBlockiert korrigiert\nKorrigierter Upload von Dateien",
9
+ "ru": "Обновленные пакеты\nИсправленная игра в vis\nИсправлено блокно\nИсправленная загрузка файлов",
10
+ "pt": "Pacotes atualizados\nJogo correto em vis\nCorrigido em bloco\nUpload corrigido de arquivos",
11
+ "nl": "Pakketten bijgewerkt\nGecorrigeerd spelen in vis\nBloksgewijs gecorrigeerd\nGecorrigeerde upload van bestanden",
12
+ "fr": "Mise à jour des paquets\nCorrigé jouer dans vis\nCorrigé en bloc\nTéléchargement corrigé des fichiers",
13
+ "it": "Pacchetti aggiornati\nCorretto giocare in vis\nCorretto in blocco\nCaricamento corretto dei file",
14
+ "es": "Paquetes actualizados\nCorregido jugando en vis\nCorregido bloqueado\nCarga corregida de archivos",
15
+ "pl": "Aktualizacja pakietów\nPoprawione gry w vis\nPoprawione blokowane\nPoprawione przesyłanie plików",
16
+ "uk": "Пакети оновлені\nПравильна гра в віках\nВиправлено блоклі\nВиправлено завантаження файлів",
17
+ "zh-cn": "更新软件包\n已校正播放相对\n块状修正\n更正了文件的上传"
18
18
  },
19
19
  "4.0.1": {
20
20
  "en": "Packages updated\nUsing the pre-calculated duration of the mp3 to wait long enough even for longer announcements",
package/main.js CHANGED
@@ -103,18 +103,22 @@ function startAdapter(options) {
103
103
  function processMessage(obj) {
104
104
  if (obj) {
105
105
  if (obj.command === 'say') {
106
- const text = obj.message.text;
106
+ const text = obj.message?.text;
107
107
  const language = obj.message?.language;
108
108
  const volume = obj.message?.volume;
109
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);
110
+ if (text) {
111
+ if (obj.callback) {
112
+ const opts = {...obj.message};
113
+ opts.callback = error => {
114
+ adapter.sendTo(obj.from, obj.command, {error, result: error ? undefined : 'Ok'}, obj.callback);
115
+ };
116
+ addToQueue(text, language, volume, null, opts);
117
+ } else {
118
+ addToQueue(text, language, volume);
119
+ }
116
120
  } else {
117
- addToQueue(text, language, volume);
121
+ adapter.sendTo(obj.from, obj.command, {error : 'No text'}, obj.callback);
118
122
  }
119
123
  } else if (obj.command === 'stopInstance') {
120
124
  stop(false, () =>
@@ -421,7 +425,7 @@ async function processTasks() {
421
425
  }
422
426
 
423
427
  if (!data) {
424
- // may be the file is from real FS
428
+ // maybe the file is from real FS
425
429
  if (fs.existsSync(text)) {
426
430
  try {
427
431
  data = fs.readFileSync(text);
@@ -442,7 +446,7 @@ async function processTasks() {
442
446
  } else {
443
447
  fileName = MP3FILE;
444
448
  }
445
- fs.writeFileSync(fileName, data);
449
+ fs.writeFileSync(fileName, data.file ? data.file : data);
446
450
  } catch (e) {
447
451
  adapter.log.error(`Cannot write file "${MP3FILE}": ${e.toString()}`);
448
452
  }
@@ -543,7 +547,9 @@ async function uploadFile(file) {
543
547
 
544
548
  if (!data) {
545
549
  try {
546
- await adapter.writeFileAsync(adapter.namespace, `tts.userfiles/${file}`, fs.readFileSync(path.join(`${__dirname}/mp3/`, file)));
550
+ data = fs.readFileSync(path.join(`${__dirname}/mp3/`, file));
551
+ adapter.log.debug(`Upload file: ${path.join(`${__dirname}/mp3/`, file)} (${data.length} bytes`);
552
+ await adapter.writeFileAsync(adapter.namespace, `tts.userfiles/${file}`, data);
547
553
  } catch (e) {
548
554
  adapter.log.error(`Cannot write file "${__dirname}/mp3/${file}": ${e.toString()}`);
549
555
  }
@@ -592,7 +598,7 @@ async function prepareAnnounceFiles(config) {
592
598
  const data = await adapter.readFileAsync(adapter.namespace, `tts.userfiles/${fileName}`);
593
599
  if (data) {
594
600
  try {
595
- fs.writeFileSync(path.join(__dirname, fileName), data);
601
+ fs.writeFileSync(path.join(__dirname, fileName), data.file ? data.file : data);
596
602
  config.announce = path.join(__dirname, fileName);
597
603
  } catch (e) {
598
604
  adapter.log.error(`Cannot write file: ${e.toString()}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iobroker.sayit",
3
- "version": "4.0.3",
3
+ "version": "4.0.5",
4
4
  "description": "Text to speech interface for ioBroker.",
5
5
  "author": {
6
6
  "name": "bluefox",