Skip to content

Commit ccaa1d5

Browse files
Yamakuprinanikvoloshin
authored andcommitted
fix lack of tokenData in ttsConfig
1 parent 0132e08 commit ccaa1d5

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/dto/config/TtsConfig.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.justai.jaicf.channel.jaicp.dto.config
22

33
import kotlinx.serialization.SerialName
44
import kotlinx.serialization.Serializable
5+
import kotlinx.serialization.json.JsonObject
56

67
/**
78
* Configuration parameters for the text-to-speech (TTS) provider used in a telephone channel.
@@ -28,6 +29,7 @@ data class TtsConfig(
2829
val azure: TtsAzureConfig? = null,
2930
val aimyvoice: TtsAimyvoiceConfig? = null,
3031
val sber: TtsSberConfig? = null,
32+
val tokenData: JsonObject? = null,
3133
) {
3234
@Serializable
3335
enum class TtsProviderType {

channels/jaicp/src/main/kotlin/com/justai/jaicf/channel/jaicp/reactions/JaicpReactions.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.justai.jaicf.channel.jaicp.dto.JaicpDialerAPI
55
import com.justai.jaicf.channel.jaicp.dto.JaicpResponseData
66
import com.justai.jaicf.channel.jaicp.dto.Reply
77
import com.justai.jaicf.channel.jaicp.dto.TextReply
8+
import com.justai.jaicf.channel.jaicp.jaicpRequest
89
import com.justai.jaicf.channel.jaicp.logging.internal.SessionManager
910
import com.justai.jaicf.context.DialogContext
1011
import com.justai.jaicf.logging.EndSessionReaction
@@ -26,6 +27,8 @@ open class JaicpReactions : Reactions() {
2627

2728
protected val responseData: MutableMap<String, JsonElement> = mutableMapOf()
2829

30+
private var ttsTokenData: JsonObject? = null
31+
2932
internal fun getCurrentState() = botContext.dialogContext.currentState
3033

3134
/**
@@ -77,6 +80,11 @@ open class JaicpReactions : Reactions() {
7780
fun collect(): JsonObject {
7881
doBeforeCollect()
7982

83+
ttsTokenData = checkNotNull(executionContext.jaicpRequest)
84+
.rawRequest.jsonObject["asrTtsProviderData"]?.jsonObject?.get("tts")?.jsonObject?.get("tokenData")?.jsonObject
85+
?: ttsTokenData
86+
val ttsConfig = telephony?.ttsConfig?.copy(tokenData = ttsTokenData?.jsonObject)
87+
8088
return JSON.encodeToJsonElement(
8189
serializer = JaicpResponseData.serializer(),
8290
value = JaicpResponseData(
@@ -86,7 +94,7 @@ open class JaicpReactions : Reactions() {
8694
bargeInInterrupt = telephony?.bargeInInterrupt,
8795
sessionId = SessionManager.get(executionContext).getOrCreateSessionId().sessionId,
8896
responseData = responseData,
89-
ttsConfig = telephony?.ttsConfig,
97+
ttsConfig = ttsConfig,
9098
asrConfig = telephony?.asrConfig
9199
)
92100
).jsonObject

0 commit comments

Comments
 (0)