fix remove speech label, cause application save wrong label (#384)

* fix remove speech label, cause application save wrong label

* fix microsoft custom_tts input
This commit is contained in:
Hoan Luu Huu
2024-01-17 21:17:25 +07:00
committed by GitHub
parent af1ba3a15c
commit dc519bdef9
2 changed files with 50 additions and 17 deletions
@@ -386,6 +386,53 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
}
}, [accountSid]);
useEffect(() => {
let label: string;
// Synthesis Label
label = application?.data?.speech_synthesis_label || "";
if (ttsLabelOptions && !ttsLabelOptions.find((l) => l.value === label)) {
label = ttsLabelOptions.length ? ttsLabelOptions[0].value : "";
}
setSynthLabel(label);
// fallback Synthesis Label
label = application?.data?.fallback_speech_synthesis_label || "";
if (
fallbackTtsLabelOptions &&
!fallbackTtsLabelOptions.find((l) => l.value === label)
) {
label = fallbackTtsLabelOptions.length
? fallbackTtsLabelOptions[0].value
: "";
}
setFallbackSpeechSynthsisLabel(label);
// regconizer label
label = application?.data?.speech_recognizer_label || "";
if (sttLabelOptions && !sttLabelOptions.find((l) => l.value === label)) {
label = sttLabelOptions.length ? sttLabelOptions[0].value : "";
}
setRecogLabel(label);
// fallback regconizer label
label = application?.data?.fallback_speech_recognizer_label || "";
if (
fallbackSttLabelOptions &&
!fallbackSttLabelOptions.find((l) => l.value === label)
) {
label = fallbackSttLabelOptions.length
? fallbackSttLabelOptions[0].value
: "";
}
setFallbackSpeechRecognizerLabel(label);
}, [
ttsLabelOptions,
sttLabelOptions,
fallbackTtsLabelOptions,
fallbackSttLabelOptions,
application,
]);
useEffect(() => {
setLocation();
if (application && application.data) {
@@ -462,12 +509,7 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
if (application.data.speech_recognizer_language)
setRecogLang(application.data.speech_recognizer_language);
if (application.data.speech_synthesis_label) {
setSynthLabel(application.data.speech_synthesis_label);
}
if (application.data.speech_recognizer_label) {
setRecogLabel(application.data.speech_recognizer_label);
}
if (application.data.use_for_fallback_speech) {
setUseForFallbackSpeech(application.data.use_for_fallback_speech > 0);
setInitalCheckFallbackSpeech(
@@ -485,11 +527,7 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
application.data.fallback_speech_recognizer_language
);
}
if (application.data.fallback_speech_recognizer_label) {
setFallbackSpeechRecognizerLabel(
application.data.fallback_speech_recognizer_label
);
}
if (application.data.fallback_speech_synthesis_vendor) {
setFallbackSpeechSynthsisVendor(
application.data
@@ -506,11 +544,6 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
application.data.fallback_speech_synthesis_voice
);
}
if (application.data.fallback_speech_synthesis_label) {
setFallbackSpeechSynthsisLabel(
application.data.fallback_speech_synthesis_label
);
}
}
}, [application]);
@@ -142,7 +142,7 @@ export const SpeechProviderSelection = ({
if (credentials) {
setSelectedCredential(
credentials.find(
(c) => c.vendor === synthVendor && c.label === synthLabel
(c) => c.vendor === synthVendor && (c.label || "") === synthLabel
)
);
}