Skip to content

Commit

Permalink
fix lack of tokenData in ttsConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamakuprina committed Nov 28, 2023
1 parent 0132e08 commit 04631f4
Show file tree
Hide file tree
Showing 2 changed files with 11 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 text-to-speech (TTS) provider used in a telephone channel.
Expand All @@ -28,6 +29,7 @@ data class TtsConfig(
val azure: TtsAzureConfig? = null,
val aimyvoice: TtsAimyvoiceConfig? = null,
val sber: TtsSberConfig? = null,
val tokenData: JsonObject? = null,
) {
@Serializable
enum class TtsProviderType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.justai.jaicf.channel.jaicp.dto.JaicpDialerAPI
import com.justai.jaicf.channel.jaicp.dto.JaicpResponseData
import com.justai.jaicf.channel.jaicp.dto.Reply
import com.justai.jaicf.channel.jaicp.dto.TextReply
import com.justai.jaicf.channel.jaicp.jaicpRequest
import com.justai.jaicf.channel.jaicp.logging.internal.SessionManager
import com.justai.jaicf.context.DialogContext
import com.justai.jaicf.logging.EndSessionReaction
Expand All @@ -26,6 +27,8 @@ open class JaicpReactions : Reactions() {

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

private var ttsTokenData: JsonObject? = null

internal fun getCurrentState() = botContext.dialogContext.currentState

/**
Expand Down Expand Up @@ -77,6 +80,11 @@ open class JaicpReactions : Reactions() {
fun collect(): JsonObject {
doBeforeCollect()

ttsTokenData = checkNotNull(executionContext.jaicpRequest)
.rawRequest.jsonObject["asrTtsProviderData"]?.jsonObject?.get("tts")?.jsonObject?.get("tokenData")?.jsonObject
?: ttsTokenData
val ttsConfig = telephony?.ttsConfig?.copy(tokenData = ttsTokenData?.jsonObject)

return JSON.encodeToJsonElement(
serializer = JaicpResponseData.serializer(),
value = JaicpResponseData(
Expand All @@ -86,7 +94,7 @@ open class JaicpReactions : Reactions() {
bargeInInterrupt = telephony?.bargeInInterrupt,
sessionId = SessionManager.get(executionContext).getOrCreateSessionId().sessionId,
responseData = responseData,
ttsConfig = telephony?.ttsConfig,
ttsConfig = ttsConfig,
asrConfig = telephony?.asrConfig
)
).jsonObject
Expand Down

0 comments on commit 04631f4

Please sign in to comment.