From a165bfc4d62b36cafc33edae32090b5d5756eb67 Mon Sep 17 00:00:00 2001 From: Hoan Luu Huu <110280845+xquanluu@users.noreply.github.com> Date: Sat, 25 Mar 2023 22:21:14 +0700 Subject: [PATCH] feat: onpremise nuance (#220) Co-authored-by: Quan HL --- src/api/types.ts | 2 + .../internal/views/speech-services/form.tsx | 167 ++++++++++++++---- 2 files changed, 139 insertions(+), 30 deletions(-) diff --git a/src/api/types.ts b/src/api/types.ts index 4d05d51..c47459f 100644 --- a/src/api/types.ts +++ b/src/api/types.ts @@ -303,6 +303,8 @@ export interface SpeechCredential { custom_stt_endpoint: null | string; client_id: null | string; secret: null | string; + nuance_tts_uri: null | string; + nuance_stt_uri: null | string; tts_api_key: null | string; tts_region: null | string; stt_api_key: null | string; diff --git a/src/containers/internal/views/speech-services/form.tsx b/src/containers/internal/views/speech-services/form.tsx index e4f9fb9..3e8c265 100644 --- a/src/containers/internal/views/speech-services/form.tsx +++ b/src/containers/internal/views/speech-services/form.tsx @@ -89,6 +89,16 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { const [customVendorTtsUrl, setCustomVendorTtsUrl] = useState(""); const [tmpCustomVendorSttUrl, setTmpCustomVendorSttUrl] = useState(""); const [customVendorSttUrl, setCustomVendorSttUrl] = useState(""); + const [initialOnPremNuanceTtsCheck, setInitialOnPremNuanceTtsCheck] = + useState(false); + const [onPremNuanceTtsCheck, setOnPremNuanceTtsCheck] = useState(false); + const [onPremNuanceTtsUrl, setOnPremNuanceTtsUrl] = useState(""); + const [tmpOnPremNuanceTtsUrl, setTmpOnPremNuanceTtsUrl] = useState(""); + const [initialOnPremNuanceSttCheck, setInitialOnPremNuanceSttCheck] = + useState(false); + const [onPremNuanceSttCheck, setOnPremNuanceSttCheck] = useState(false); + const [tmpOnPremNuanceSttUrl, setTmpOnPremNuanceSttUrl] = useState(""); + const [onPremNuanceSttUrl, setOnPremNuanceSttUrl] = useState(""); const handleFile = (file: File) => { const handleError = () => { @@ -161,6 +171,12 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { custom_stt_url: customVendorSttUrl || null, auth_token: customVendorAuthToken || null, }), + ...(vendor === VENDOR_NUANCE && { + client_id: clientId || null, + secret: secretKey || null, + nuance_tts_uri: onPremNuanceTtsUrl || null, + nuance_stt_uri: onPremNuanceSttUrl || null, + }), }; if (credential && credential.data) { @@ -197,8 +213,6 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { vendor === VENDOR_SONIOX ? apiKey : null, - client_id: vendor === VENDOR_NUANCE ? clientId : null, - secret: vendor === VENDOR_NUANCE ? secretKey : null, riva_server_uri: vendor == VENDOR_NVIDIA ? rivaServerUri : null, }) .then(() => { @@ -219,7 +233,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { if (credential.data.vendor) { const v = credential.data.vendor.startsWith(VENDOR_CUSTOM) ? VENDOR_CUSTOM - : vendor; + : credential.data.vendor; setVendor(v); } @@ -275,6 +289,24 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { setSecretKey(credential.data.secret); } + if (credential.data.nuance_tts_uri) { + setOnPremNuanceTtsUrl(credential.data.nuance_tts_uri); + setInitialOnPremNuanceTtsCheck(true); + setOnPremNuanceTtsCheck(true); + } else { + setInitialOnPremNuanceTtsCheck(false); + setOnPremNuanceTtsCheck(false); + } + + if (credential.data.nuance_stt_uri) { + setOnPremNuanceSttUrl(credential.data.nuance_stt_uri); + setInitialOnPremNuanceSttCheck(true); + setOnPremNuanceSttCheck(true); + } else { + setInitialOnPremNuanceSttCheck(false); + setOnPremNuanceSttCheck(false); + } + if (credential.data.tts_api_key) { setTtsApiKey(credential.data.tts_api_key); } @@ -527,33 +559,108 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { )} {vendor === VENDOR_NUANCE && ( -
- - setClientId(e.target.value)} - disabled={credential ? true : false} - /> - - setSecretKey(e.target.value)} - disabled={credential ? true : false} - /> -
+ <> +
+ + setClientId(e.target.value)} + disabled={credential ? true : false} + /> + + setSecretKey(e.target.value)} + disabled={credential ? true : false} + /> +
+
+ <> + + + + +
+ )} {vendor === VENDOR_AWS && (