diff --git a/src/api/types.ts b/src/api/types.ts index b5dce58..e29cf3f 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -231,6 +231,10 @@ export interface SpeechCredential { access_key_id: null | string; secret_access_key: null | string; service_key: null | string; + use_custom_tts: number; + custom_tts_endpoint: null | string; + use_custom_stt: number; + custom_stt_endpoint: null | string; } export interface Alert { diff --git a/src/containers/internal/views/speech-services/form.tsx b/src/containers/internal/views/speech-services/form.tsx index 7862c81..e4326d0 100644 --- a/src/containers/internal/views/speech-services/form.tsx +++ b/src/containers/internal/views/speech-services/form.tsx @@ -53,6 +53,12 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { const [secretAccessKey, setSecretAccessKey] = useState(""); const [googleServiceKey, setGoogleServiceKey] = useState(null); + const [useCustomTts, setUseCustomTts] = useState(false); + const [useCustomStt, setUseCustomStt] = useState(false); + const [customTtsEndpoint, setCustomTtsEndpoint] = useState(""); + const [tmpCustomTtsEndpoint, setTmpCustomTtsEndpoint] = useState(""); + const [customSttEndpoint, setCustomSttEndpoint] = useState(""); + const [tmpCustomSttEndpoint, setTmpCustomSttEndpoint] = useState(""); const handleFile = (file: File) => { const handleError = () => { @@ -91,8 +97,16 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { currentServiceProvider.service_provider_sid || null, use_for_tts: ttsCheck ? 1 : 0, use_for_stt: sttCheck ? 1 : 0, - aws_region: vendor === VENDOR_AWS ? region : null, - region: vendor === VENDOR_MICROSOFT ? region : null, + ...(vendor === VENDOR_AWS && { + aws_region: region || null, + }), + ...(vendor === VENDOR_MICROSOFT && { + region: region || null, + use_custom_tts: useCustomTts ? 1 : 0, + custom_tts_endpoint: customTtsEndpoint || null, + use_custom_stt: useCustomStt ? 1 : 0, + custom_stt_endpoint: customSttEndpoint || null, + }), }; if (credential && credential.data) { @@ -180,6 +194,11 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { if (credential.data.aws_region) { setRegion(credential.data.aws_region); } + + setUseCustomTts(credential.data.use_custom_tts > 0 ? true : false); + setUseCustomStt(credential.data.use_custom_stt > 0 ? true : false); + setCustomTtsEndpoint(credential.data.custom_tts_endpoint || ""); + setCustomSttEndpoint(credential.data.custom_stt_endpoint || ""); } }, [credential]); @@ -351,10 +370,83 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { }, ].concat(regions[vendor as keyof RegionVendors])} onChange={(e) => setRegion(e.target.value)} - disabled={credential ? true : false} /> )} + {vendor === VENDOR_MICROSOFT && ( + +
+ + + setCustomTtsEndpoint(e.target.value)} + /> +
+
+ + + setCustomSttEndpoint(e.target.value)} + /> +
+
+ )}