fix choose speech dedential by label (#315)

This commit is contained in:
Hoan Luu Huu
2023-08-30 20:22:39 +07:00
committed by GitHub
parent 72de9178a2
commit 75e7785061
2 changed files with 60 additions and 54 deletions

View File

@@ -42,7 +42,7 @@ export const Selector = forwardRef<SelectorRef, SelectorProps>(
{...restProps}
>
{options.map((option) => (
<option key={option.value} value={option.value}>
<option key={`${id}_${option.value}`} value={option.value}>
{option.name}
</option>
))}

View File

@@ -290,17 +290,17 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
const noneLabelObject = {
name: "None",
value: null,
value: "",
};
let labels = credentials
.filter(
(c) =>
c.label &&
c.vendor === synthVendor &&
c.account_sid === accountSid &&
c.use_for_tts
)
let c1 = credentials.filter(
(c) =>
c.vendor === synthVendor &&
(!c.account_sid || c.account_sid === accountSid) &&
c.use_for_tts
);
let c2 = c1
.filter((c) => c.label)
.map((c) =>
Object.assign({
name: c.label,
@@ -308,37 +308,39 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
})
);
setTtsLabelOptions([noneLabelObject, ...labels]);
setTtsLabelOptions(
c1.length !== c2.length ? [noneLabelObject, ...c2] : c2
);
labels = fallbackSpeechSynthsisVendor
? credentials
.filter(
(c) =>
c.label &&
c.vendor === fallbackSpeechSynthsisVendor &&
c.account_sid === accountSid &&
c.use_for_tts
)
.map((c) =>
Object.assign({
name: c.label,
value: c.label,
})
)
c1 = fallbackSpeechSynthsisVendor
? credentials.filter(
(c) =>
c.vendor === fallbackSpeechSynthsisVendor &&
(!c.account_sid || c.account_sid === accountSid) &&
c.use_for_tts
)
: [];
console.log(labels);
c2 = c1
.filter((c) => c.label)
.map((c) =>
Object.assign({
name: c.label,
value: c.label,
})
);
setFallbackTtsLabelOptions(
c1.length !== c2.length ? [noneLabelObject, ...c2] : c2
);
setFallbackTtsLabelOptions([noneLabelObject, ...labels]);
labels = credentials
.filter(
(c) =>
c.label &&
c.vendor === recogVendor &&
c.account_sid === accountSid &&
c.use_for_stt
)
c1 = credentials.filter(
(c) =>
c.vendor === recogVendor &&
(!c.account_sid || c.account_sid === accountSid) &&
c.use_for_stt
);
c2 = c1
.filter((c) => c.label)
.map((c) =>
Object.assign({
name: c.label,
@@ -346,26 +348,30 @@ export const ApplicationForm = ({ application }: ApplicationFormProps) => {
})
);
setSttLabelOptions([noneLabelObject, ...labels]);
setSttLabelOptions(
c1.length !== c2.length ? [noneLabelObject, ...c2] : c2
);
labels = fallbackSpeechRecognizerVendor
? credentials
.filter(
(c) =>
c.label &&
c.vendor === fallbackSpeechRecognizerVendor &&
c.account_sid === accountSid &&
c.use_for_stt
)
.map((c) =>
Object.assign({
name: c.label,
value: c.label,
})
)
c1 = fallbackSpeechRecognizerVendor
? credentials.filter(
(c) =>
c.vendor === fallbackSpeechRecognizerVendor &&
(!c.account_sid || c.account_sid === accountSid) &&
c.use_for_stt
)
: [];
c2 = c1
.filter((c) => c.label)
.map((c) =>
Object.assign({
name: c.label,
value: c.label,
})
);
setFallbackSttLabelOptions([noneLabelObject, ...labels]);
setFallbackSttLabelOptions(
c1.length !== c2.length ? [noneLabelObject, ...c2] : c2
);
}
}, [
credentials,