say verb support play audio in array (#482)

* say verb support play audio in array

* fixed review comments

* added separated testcase
This commit is contained in:
Hoan Luu Huu
2023-10-20 13:14:57 +07:00
committed by GitHub
parent 1ff4f01d64
commit 4b7b0e309b
2 changed files with 50 additions and 1 deletions

View File

@@ -50,6 +50,15 @@ class TaskSay extends Task {
return `${this.name}{${this.text[0]}}`;
}
_validateURL(urlString) {
try {
new URL(urlString);
return true;
} catch (e) {
return false;
}
}
async _synthesizeWithSpecificVendor(cs, ep, {vendor, language, voice, label}) {
const {srf} = cs;
const {updateSpeechCredentialLastUsed} = require('../utils/db-utils')(this.logger, srf);
@@ -153,7 +162,7 @@ class TaskSay extends Task {
}
};
const arr = this.text.map((t) => generateAudio(t));
const arr = this.text.map((t) => (this._validateURL(t) ? t : generateAudio(t)));
return (await Promise.all(arr)).filter((fp) => fp && fp.length);
} catch (err) {
this.logger.info(err, 'TaskSay:exec error');