UNPKG

@cognigy/rest-api-client

Version:

Cognigy REST-Client

341 lines 10.7 kB
import { __awaiter } from "tslib"; /** Custom Modules */ import { createNodeDescriptor } from "../../../createNodeDescriptor"; /** Helper Modules */ import { setSessionConfig, voiceConfigParamsToVoiceSettings } from "../mappers/setSessionConfig.mapper"; import { nodeColor } from "../utils/design"; import { GoogleSpeechModel } from "../utils/vgConstants"; import { logFullConfigToDebugMode } from "../../../../helper/logFullConfigToDebugMode"; export const voiceConfigFields = [ { key: "sttHints", type: "textArray", label: "UI__NODE_EDITOR__STT_HINTS__LABEL", description: "UI__NODE_EDITOR__STT_HINTS__DESCRIPTION", defaultValue: [""], condition: { or: [ { key: "sttVendor", value: "microsoft", }, { key: "sttVendor", value: "google", }, { key: "sttVendor", value: "aws", }, { key: "sttVendor", value: "soniox" } ] } }, { key: "sttHintsDynamicHints", type: "cognigyText", label: "UI__NODE_EDITOR__STT_HINTS_DYNAMIC_HINTS__LABEL", description: "UI__NODE_EDITOR__STT_HINTS_DYNAMIC_HINTS__DESCRIPTION", defaultValue: "", condition: { or: [ { key: "sttVendor", value: "microsoft", }, { key: "sttVendor", value: "google", }, { key: "sttVendor", value: "aws", }, { key: "sttVendor", value: "soniox" } ] } }, { key: "sttDisablePunctuation", type: "toggle", label: "UI__NODE_EDITOR__STT_DISABLE_PUNCTUATION__LABEL", description: "UI__NODE_EDITOR__STT_DISABLE_PUNCTUATION__DESCRIPTION", defaultValue: false, condition: { or: [ { key: "sttVendor", value: "google", }, { key: "sttVendor", value: "deepgram", }, ] } }, { key: "deepgramEndpointing", type: "toggle", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING__LABEL", description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING__DESCRIPTION", defaultValue: true, condition: { key: "sttVendor", value: "deepgram" } }, { key: "deepgramEndpointingValue", type: "number", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING_TIME__LABEL", description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_ENDPOINTING_TIME__DESCRIPTION", defaultValue: 250, params: { min: 10, max: 1000 }, condition: { and: [ { key: "sttVendor", value: "deepgram" }, { key: "deepgramEndpointing", value: true }, ] } }, { key: "deepgramSmartFormatting", type: "toggle", label: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_SMART_FORMATTING__LABEL", description: "UI__NODE_EDITOR__VOICEGATEWAY2__SET_SESSION_CONFIG__DEEPGRAM_SMART_FORMATTING__DESCRIPTION", defaultValue: false, condition: { key: "sttVendor", value: "deepgram" } }, { key: "enableAdvancedSTTConfig", type: "toggle", label: "UI__NODE_EDITOR__ENABLE_ADVANCED_STT_CONFIG__LABEL", description: "UI__NODE_EDITOR__ENABLE_ADVANCED_STT_CONFIG__DESCRIPTION", defaultValue: false, condition: { key: "sttVendor", value: "microsoft" } }, { key: "azureSttContextId", type: "cognigyText", label: "UI__NODE_EDITOR__AZURE_STT_CONTEXT_ID__LABEL", description: "UI__NODE_EDITOR__AZURE_STT_CONTEXT_ID__DESCRIPTION", defaultValue: "", condition: { and: [ { key: "enableAdvancedSTTConfig", value: true }, { key: "sttVendor", value: "microsoft" } ] } }, { key: "azureEnableAudioLogging", type: "toggle", label: "UI__NODE_EDITOR__AZURE_ENABLE_AUDIO_LOGGING__LABEL", description: "UI__NODE_EDITOR__AZURE_ENABLE_AUDIO_LOGGING__DESCRIPTION", defaultValue: false, condition: { and: [ { key: "enableAdvancedSTTConfig", value: true }, { key: "sttVendor", value: "microsoft" } ] } }, { key: "googleModel", type: "select", label: "UI__NODE_EDITOR__GOOGLE_MODEL__LABEL", description: "UI__NODE_EDITOR__GOOGLE_MODEL__DESCRIPTION", defaultValue: GoogleSpeechModel.LatestShort, condition: { key: "sttVendor", value: "google" }, params: { options: [ { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__LATEST_SHORT__LABEL", value: GoogleSpeechModel.LatestShort, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__LATEST_LONG__LABEL", value: GoogleSpeechModel.LatestLong, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__COMMAND_AND_SEARCH__LABEL", value: GoogleSpeechModel.CommandAndSearch, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__PHONE_CALL__LABEL", value: GoogleSpeechModel.PhoneCall, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__VIDEO__LABEL", value: GoogleSpeechModel.Video, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__MEDICAL_DICTATION__LABEL", value: GoogleSpeechModel.MedicalDictation, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__MEDICAL_CONVERSATION__LABEL", value: GoogleSpeechModel.MedicalConversation, }, { label: "UI__NODE_EDITOR__GOOGLE_MODEL__OPTIONS__DEFAULT__LABEL", value: GoogleSpeechModel.Default, }, ], }, }, { key: "ttsVendor", type: "ttsSelect", label: "_unused_", description: "_unused_", defaultValue: "", params: { modelKey: "config.ttsModel", languageKey: "config.ttsLanguage", voiceKey: "config.ttsVoice" } }, { key: "ttsModel", type: "ttsSelect", label: "_unused_", description: "_unused_", defaultValue: "", }, { key: "ttsVoice", type: "ttsSelect", label: "_unused_", description: "_unused_", defaultValue: "", }, { key: "ttsLanguage", type: "ttsSelect", label: "_unused_", description: "_unused_", defaultValue: "", }, { key: "sttVendor", type: "sttSelect", label: "_unused_", description: "_unused_", defaultValue: "", params: { languageKey: "config.sttLanguage", modelKey: "config.sttDeepgramModel", } }, { key: "sttLanguage", type: "sttSelect", label: "_unused_", description: "_unused_", defaultValue: "", }, { key: "sttDeepgramModel", type: "sttSelect", label: "_unused_", description: "_unused_", defaultValue: "", condition: { key: "sttVendor", value: "deepgram" } }, ]; export const SESSION_SPEECH_PARAMETERS = createNodeDescriptor({ type: "sessionSpeechParameters", defaultLabel: "Session Speech Parameters - Config", summary: "UI__NODE_EDITOR__SESSION_SPEECH_PARAMETERS__SUMMARY", appearance: { color: nodeColor, }, tags: [""], fields: voiceConfigFields, sections: [ { key: "params_stt", label: "UI__NODE_EDITOR__SESSION_SPEECH_PARAMETERS__SECTIONS__PARAMS_STT__LABEL", defaultCollapsed: true, fields: [ "sttVendor", "deepgramEndpointing", "deepgramEndpointingValue", "deepgramSmartFormatting", "sttHints", "sttHintsDynamicHints", "googleModel", "sttDisablePunctuation", "enableAdvancedSTTConfig", "azureSttContextId", "azureEnableAudioLogging" ], }, { key: "params_tts", label: "UI__NODE_EDITOR__SESSION_SPEECH_PARAMETERS__SECTIONS__PARAMS_TTS__LABEL", defaultCollapsed: true, fields: ["ttsVendor"], }, ], form: [ { type: "section", key: "params_tts" }, { type: "section", key: "params_stt" }, ], function: ({ cognigy, config }) => __awaiter(void 0, void 0, void 0, function* () { const { api, input } = cognigy; const { endpointType } = input; try { const payload = setSessionConfig.handleInput(endpointType, voiceConfigParamsToVoiceSettings(config, api)); yield api.say(null, { _cognigy: payload, }); logFullConfigToDebugMode(cognigy, config); } catch (error) { throw new Error(`Error on Session Speech Parameters node. Error message: ${error.message}`); } }), }); //# sourceMappingURL=sessionSpeechParameters.js.map