stt/tts label can be empty, should not assign application level label… (#804)

* stt/tts label can be empty, should not assign application level label as default value

* wip
This commit is contained in:
Hoan Luu Huu
2024-07-10 21:36:00 +07:00
committed by GitHub
parent 8672152873
commit 5ccea65b7f
3 changed files with 27 additions and 21 deletions

View File

@@ -141,9 +141,8 @@ class TaskConfig extends Task {
cs.speechSynthesisVendor = this.synthesizer.vendor !== 'default' cs.speechSynthesisVendor = this.synthesizer.vendor !== 'default'
? this.synthesizer.vendor ? this.synthesizer.vendor
: cs.speechSynthesisVendor; : cs.speechSynthesisVendor;
cs.speechSynthesisLabel = this.synthesizer.label !== 'default' cs.speechSynthesisLabel = this.synthesizer.label === 'default'
? this.synthesizer.label ? cs.speechSynthesisLabel : this.synthesizer.label;
: cs.speechSynthesisLabel;
cs.speechSynthesisLanguage = this.synthesizer.language !== 'default' cs.speechSynthesisLanguage = this.synthesizer.language !== 'default'
? this.synthesizer.language ? this.synthesizer.language
: cs.speechSynthesisLanguage; : cs.speechSynthesisLanguage;
@@ -155,15 +154,16 @@ class TaskConfig extends Task {
cs.fallbackSpeechSynthesisVendor = this.synthesizer.fallbackVendor !== 'default' cs.fallbackSpeechSynthesisVendor = this.synthesizer.fallbackVendor !== 'default'
? this.synthesizer.fallbackVendor ? this.synthesizer.fallbackVendor
: cs.fallbackSpeechSynthesisVendor; : cs.fallbackSpeechSynthesisVendor;
cs.fallbackSpeechSynthesisLabel = this.synthesizer.fallbackLabel !== 'default' cs.fallbackSpeechSynthesisLabel = this.synthesizer.fallbackLabel === 'default'
? this.synthesizer.fallbackLabel ? cs.fallbackSpeechSynthesisLabel : this.synthesizer.fallbackLabel;
: cs.fallbackSpeechSynthesisLabel;
cs.fallbackSpeechSynthesisLanguage = this.synthesizer.fallbackLanguage !== 'default' cs.fallbackSpeechSynthesisLanguage = this.synthesizer.fallbackLanguage !== 'default'
? this.synthesizer.fallbackLanguage ? this.synthesizer.fallbackLanguage
: cs.fallbackSpeechSynthesisLanguage; : cs.fallbackSpeechSynthesisLanguage;
cs.fallbackSpeechSynthesisVoice = this.synthesizer.fallbackVoice !== 'default' cs.fallbackSpeechSynthesisVoice = this.synthesizer.fallbackVoice !== 'default'
? this.synthesizer.fallbackVoice ? this.synthesizer.fallbackVoice
: cs.fallbackSpeechSynthesisVoice; : cs.fallbackSpeechSynthesisVoice;
// new vendor is set, reset fallback vendor
cs.hasFallbackTts = false;
this.logger.info({synthesizer: this.synthesizer}, 'Config: updated synthesizer'); this.logger.info({synthesizer: this.synthesizer}, 'Config: updated synthesizer');
} }
if (this.hasRecognizer) { if (this.hasRecognizer) {
@@ -171,9 +171,8 @@ class TaskConfig extends Task {
cs.speechRecognizerVendor = this.recognizer.vendor !== 'default' cs.speechRecognizerVendor = this.recognizer.vendor !== 'default'
? this.recognizer.vendor ? this.recognizer.vendor
: cs.speechRecognizerVendor; : cs.speechRecognizerVendor;
cs.speechRecognizerLabel = this.recognizer.label !== 'default' cs.speechRecognizerLabel = this.recognizer.label === 'default'
? this.recognizer.label ? cs.speechRecognizerLabel : this.recognizer.label;
: cs.speechRecognizerLabel;
cs.speechRecognizerLanguage = this.recognizer.language !== 'default' cs.speechRecognizerLanguage = this.recognizer.language !== 'default'
? this.recognizer.language ? this.recognizer.language
: cs.speechRecognizerLanguage; : cs.speechRecognizerLanguage;
@@ -182,9 +181,9 @@ class TaskConfig extends Task {
cs.fallbackSpeechRecognizerVendor = this.recognizer.fallbackVendor !== 'default' cs.fallbackSpeechRecognizerVendor = this.recognizer.fallbackVendor !== 'default'
? this.recognizer.fallbackVendor ? this.recognizer.fallbackVendor
: cs.fallbackSpeechRecognizerVendor; : cs.fallbackSpeechRecognizerVendor;
cs.fallbackSpeechRecognizerLabel = this.recognizer.fallbackLabel !== 'default' cs.fallbackSpeechRecognizerLabel = this.recognizer.fallbackLabel === 'default' ?
? this.recognizer.fallbackLabel cs.fallbackSpeechRecognizerLabel :
: cs.fallbackSpeechRecognizerLabel; this.recognizer.fallbackLabel;
cs.fallbackSpeechRecognizerLanguage = this.recognizer.fallbackLanguage !== 'default' cs.fallbackSpeechRecognizerLanguage = this.recognizer.fallbackLanguage !== 'default'
? this.recognizer.fallbackLanguage ? this.recognizer.fallbackLanguage
: cs.fallbackSpeechRecognizerLanguage; : cs.fallbackSpeechRecognizerLanguage;
@@ -208,6 +207,8 @@ class TaskConfig extends Task {
if ('punctuation' in this.recognizer) { if ('punctuation' in this.recognizer) {
cs.globalSttPunctuation = this.recognizer.punctuation; cs.globalSttPunctuation = this.recognizer.punctuation;
} }
// new vendor is set, reset fallback vendor
cs.hasFallbackAsr = false;
this.logger.info({ this.logger.info({
recognizer: this.recognizer, recognizer: this.recognizer,
isContinuousAsr: cs.isContinuousAsr isContinuousAsr: cs.isContinuousAsr

View File

@@ -218,9 +218,10 @@ class TaskSay extends TtsTask {
let voice = this.synthesizer.voice && this.synthesizer.voice !== 'default' ? let voice = this.synthesizer.voice && this.synthesizer.voice !== 'default' ?
this.synthesizer.voice : this.synthesizer.voice :
cs.speechSynthesisVoice; cs.speechSynthesisVoice;
let label = this.synthesizer.label && this.synthesizer.label !== 'default' ? // label can be null/empty in synthesizer config, just use application level label if it's default
this.synthesizer.label : let label = this.synthesizer.label === 'default' ?
cs.speechSynthesisLabel; cs.speechSynthesisLabel :
this.synthesizer.label;
const fallbackVendor = this.synthesizer.fallbackVendor && this.synthesizer.fallbackVendor !== 'default' ? const fallbackVendor = this.synthesizer.fallbackVendor && this.synthesizer.fallbackVendor !== 'default' ?
this.synthesizer.fallbackVendor : this.synthesizer.fallbackVendor :
@@ -231,9 +232,10 @@ class TaskSay extends TtsTask {
const fallbackVoice = this.synthesizer.fallbackVoice && this.synthesizer.fallbackVoice !== 'default' ? const fallbackVoice = this.synthesizer.fallbackVoice && this.synthesizer.fallbackVoice !== 'default' ?
this.synthesizer.fallbackVoice : this.synthesizer.fallbackVoice :
cs.fallbackSpeechSynthesisVoice; cs.fallbackSpeechSynthesisVoice;
const fallbackLabel = this.synthesizer.fallbackLabel && this.synthesizer.fallbackLabel !== 'default' ? // label can be null/empty in synthesizer config, just use application level label if it's default
this.synthesizer.fallbackLabel : const fallbackLabel = this.synthesizer.fallbackLabel === 'default' ?
cs.fallbackSpeechSynthesisLabel; cs.fallbackSpeechSynthesisLabel :
this.synthesizer.fallbackLabel;
if (cs.hasFallbackTts) { if (cs.hasFallbackTts) {
vendor = fallbackVendor; vendor = fallbackVendor;

View File

@@ -33,7 +33,8 @@ class SttTask extends Task {
//fallback //fallback
this.fallbackVendor = recognizer.fallbackVendor || 'default'; this.fallbackVendor = recognizer.fallbackVendor || 'default';
this.fallbackLanguage = recognizer.fallbackLanguage || 'default'; this.fallbackLanguage = recognizer.fallbackLanguage || 'default';
this.fallbackLabel = recognizer.fallbackLabel || 'default'; // label can be empty and should not have default value.
this.fallbackLabel = recognizer.fallbackLabel;
/* let credentials be supplied in the recognizer object at runtime */ /* let credentials be supplied in the recognizer object at runtime */
this.sttCredentials = setSpeechCredentialsAtRuntime(recognizer); this.sttCredentials = setSpeechCredentialsAtRuntime(recognizer);
@@ -81,7 +82,8 @@ class SttTask extends Task {
this.language = cs.speechRecognizerLanguage; this.language = cs.speechRecognizerLanguage;
if (this.data.recognizer) this.data.recognizer.language = this.language; if (this.data.recognizer) this.data.recognizer.language = this.language;
} }
if ('default' === this.label || !this.label) { // label can be empty, should not assign application level label
if ('default' === this.label) {
this.label = cs.speechRecognizerLabel; this.label = cs.speechRecognizerLabel;
if (this.data.recognizer) this.data.recognizer.label = this.label; if (this.data.recognizer) this.data.recognizer.label = this.label;
} }
@@ -94,7 +96,8 @@ class SttTask extends Task {
this.fallbackLanguage = cs.fallbackSpeechRecognizerLanguage; this.fallbackLanguage = cs.fallbackSpeechRecognizerLanguage;
if (this.data.recognizer) this.data.recognizer.fallbackLanguage = this.fallbackLanguage; if (this.data.recognizer) this.data.recognizer.fallbackLanguage = this.fallbackLanguage;
} }
if ('default' === this.fallbackLabel || !this.fallbackLabel) { // label can be empty, should not assign application level label
if ('default' === this.fallbackLabel) {
this.fallbackLabel = cs.fallbackSpeechRecognizerLabel; this.fallbackLabel = cs.fallbackSpeechRecognizerLabel;
if (this.data.recognizer) this.data.recognizer.fallbackLabel = this.fallbackLabel; if (this.data.recognizer) this.data.recognizer.fallbackLabel = this.fallbackLabel;
} }