Skip to content

Commit

Permalink
feature: add set asr properties telephony reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamakuprina committed May 15, 2024
1 parent 2fa32bf commit 19d82a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.justai.jaicf.channel.jaicp.dto.config

import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonObject

/**
* Configuration parameters for the automatic speech recognition (ASR) provider used in a telephone channel.
Expand All @@ -18,6 +19,7 @@ import kotlinx.serialization.Serializable
* @param azure configuration options for the Azure ASR provider, if used.
* @param asm configuration options for the ASM ASR provider, if used.
* @param sber configuration options for the Sber ASR provider, if used.
* @param asrProperties special properties used with selected ASR, if used.
**/
@Serializable
data class AsrConfig(
Expand All @@ -30,7 +32,8 @@ data class AsrConfig(
val mts: AsrMtsConfig? = null,
val azure: AsrAzureConfig? = null,
val asm: AsrAsmConfig? = null,
val sber: AsrSberConfig? = null
val sber: AsrSberConfig? = null,
val asrProperties: JsonObject? = null
) {
@Serializable
enum class AsrProviderType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import com.justai.jaicf.logging.SayReaction
import com.justai.jaicf.logging.currentState
import com.justai.jaicf.plugin.PathValue
import com.justai.jaicf.reactions.Reactions
import kotlinx.serialization.json.JsonObject
import kotlinx.serialization.json.JsonPrimitive
import java.time.DayOfWeek
import java.time.Duration
import java.time.Instant
Expand Down Expand Up @@ -201,6 +203,25 @@ class TelephonyReactions(private val bargeInDefaultProps: BargeInProperties) : J
)
}

/**
* This method overrides the ASR properties of the ASR used for the current call.
* example usage:
* ```
* state("asr") {
* action {
* reactions.telephony?.setAsrProperties(
* mapOf("enable_profanity_filter" to "true")
* )
* }
* }
* ```
* @param properties map of properties names with its assigned values.
* */
fun setAsrProperties(properties: Map<String, String>) {
val propertiesJson = JsonObject(properties.toMutableMap().mapValues { entry -> JsonPrimitive(entry.value) })
asrConfig = asrConfig?.copy(asrProperties = propertiesJson)
}

/**
* Schedules a redial in outbound call campaign.
*
Expand Down

0 comments on commit 19d82a2

Please sign in to comment.