diff --git a/src/api/index.ts b/src/api/index.ts index 3eb253c..abf9d9b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -875,6 +875,7 @@ export const getSpeechSupportedLanguagesAndVoices = ( sid: string | undefined, vendor: string, label: string, + create_new: boolean = false, ) => { const userData = parseJwt(getToken()); const apiUrl = @@ -883,7 +884,7 @@ export const getSpeechSupportedLanguagesAndVoices = ( : `${API_SERVICE_PROVIDERS}/${sid}`) + `/SpeechCredentials/speech/supportedLanguagesAndVoices?vendor=${vendor}${ label ? `&label=${label}` : "" - }`; + }${create_new ? "&create_new=true" : ""}`; return getFetch(apiUrl); }; diff --git a/src/containers/internal/views/applications/speech-selection.tsx b/src/containers/internal/views/applications/speech-selection.tsx index 2e3db66..2155b18 100644 --- a/src/containers/internal/views/applications/speech-selection.tsx +++ b/src/containers/internal/views/applications/speech-selection.tsx @@ -29,6 +29,7 @@ import { VENDOR_WELLSAID, VENDOR_WHISPER, VENDOR_SPEECHMATICS, + VENDOR_PLAYHT, } from "src/vendor"; import { LabelOptions, @@ -199,6 +200,19 @@ export const SpeechProviderSelection = ({ if (synthesisGoogleCustomVoiceOptions.length > 0) { updateTtsVoice(synthesisGoogleCustomVoiceOptions[0].value); } + } + // PlayHT3.0 all voices are listed under english language, all voices can be used for multiple languages + else if ( + synthVendor === VENDOR_PLAYHT && + synthesisSupportedLanguagesAndVoices.tts.some( + (l) => l.value === "english", + ) + ) { + setSynthesisVoiceOptions( + synthesisSupportedLanguagesAndVoices.tts.find( + (tts) => tts.value === "english", + )!.voices, + ); } else { setSynthesisVoiceOptions(voicesOpts); } @@ -262,6 +276,14 @@ export const SpeechProviderSelection = ({ updateTtsVoice(newLang!.voices[0].value); return; } + if (synthVendor === VENDOR_PLAYHT) { + const newLang = json.tts.find( + (lang) => lang.value === LANG_EN_US || lang.value === "english", + ); + setSynthLang(newLang!.value); + updateTtsVoice(newLang!.voices[0].value); + return; + } /** Google and AWS have different language lists */ /** If the new language doesn't map then default to "en-US" */ let newLang = json.tts.find((lang) => lang.value === synthLang); @@ -385,6 +407,7 @@ export const SpeechProviderSelection = ({ value={synthLabel} options={ttsLabelOptions} onChange={(e) => { + shouldUpdateTtsVoice.current = true; setSynthLabel(e.target.value); }} /> @@ -412,7 +435,9 @@ export const SpeechProviderSelection = ({ id="synthesis_lang" name="synthesis_lang" value={synthLang} - options={synthesisLanguageOptions} + options={synthesisLanguageOptions.sort((a, b) => + a.name.localeCompare(b.name), + )} onChange={(e) => { shouldUpdateTtsVoice.current = true; const language = e.target.value; @@ -467,7 +492,9 @@ export const SpeechProviderSelection = ({ id="synthesis_voice" name="synthesis_voice" value={synthVoice} - options={synthesisVoiceOptions} + options={synthesisVoiceOptions.sort((a, b) => + a.name.localeCompare(b.name), + )} onChange={(e) => setSynthVoice(e.target.value)} /> )} diff --git a/src/containers/internal/views/speech-services/form.tsx b/src/containers/internal/views/speech-services/form.tsx index 3e31105..2c3298e 100644 --- a/src/containers/internal/views/speech-services/form.tsx +++ b/src/containers/internal/views/speech-services/form.tsx @@ -473,6 +473,7 @@ export const SpeechServiceForm = ({ credential }: SpeechServiceFormProps) => { currentServiceProvider?.service_provider_sid, vendor, "", + credential ? false : true, ).then(({ json }) => { if (json.models) { setTtsModels(json.models); diff --git a/src/vendor/types.ts b/src/vendor/types.ts index 9074f69..f2e2d51 100644 --- a/src/vendor/types.ts +++ b/src/vendor/types.ts @@ -106,6 +106,7 @@ export interface SynthesisVendors { elevenlabs: VoiceLanguage[]; whisper: VoiceLanguage[]; deepgram: VoiceLanguage[]; + playht: VoiceLanguage[]; } export interface MSRawSpeech {