more code matching for skill launch
This commit is contained in:
@@ -143,6 +143,48 @@ public sealed class ResponsePlanToSocketMessagesMapper
|
||||
];
|
||||
}
|
||||
|
||||
public static IReadOnlyList<SocketReplyPlan> MapNoInput(string transId, IReadOnlyList<string> rules)
|
||||
{
|
||||
return
|
||||
[
|
||||
new SocketReplyPlan(JsonSerializer.Serialize(new
|
||||
{
|
||||
type = "LISTEN",
|
||||
transID = transId,
|
||||
data = new
|
||||
{
|
||||
asr = new
|
||||
{
|
||||
confidence = 0.95,
|
||||
final = true,
|
||||
text = string.Empty
|
||||
},
|
||||
nlu = new
|
||||
{
|
||||
confidence = 0.95,
|
||||
intent = string.Empty,
|
||||
rules,
|
||||
entities = new Dictionary<string, object?>()
|
||||
},
|
||||
match = new
|
||||
{
|
||||
intent = string.Empty,
|
||||
rule = rules.FirstOrDefault() ?? string.Empty,
|
||||
score = 0.95
|
||||
}
|
||||
}
|
||||
})),
|
||||
new SocketReplyPlan(JsonSerializer.Serialize(new
|
||||
{
|
||||
type = "EOS",
|
||||
ts = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
|
||||
msgID = CreateHubMessageId(),
|
||||
transID = transId,
|
||||
data = new { }
|
||||
}))
|
||||
];
|
||||
}
|
||||
|
||||
private static IReadOnlyList<string> ReadRules(TurnContext turn, string? messageType)
|
||||
{
|
||||
var attributeName = string.Equals(messageType, "CLIENT_NLU", StringComparison.OrdinalIgnoreCase)
|
||||
|
||||
@@ -150,9 +150,9 @@ public sealed class WebSocketTurnFinalizationService(
|
||||
ResetBufferedAudio(session);
|
||||
session.TurnState.SawListen = false;
|
||||
session.TurnState.SawContext = false;
|
||||
return ResponsePlanToSocketMessagesMapper.MapCompletionOnly(
|
||||
return ResponsePlanToSocketMessagesMapper.MapNoInput(
|
||||
session.TurnState.TransId ?? session.LastTransId ?? string.Empty,
|
||||
"@be/word-of-the-day")
|
||||
session.TurnState.ListenRules)
|
||||
.Select(map => new WebSocketReply
|
||||
{
|
||||
Text = map.Text,
|
||||
@@ -433,7 +433,15 @@ public sealed class WebSocketTurnFinalizationService(
|
||||
ResetBufferedAudio(session);
|
||||
turnState.SawListen = false;
|
||||
turnState.SawContext = false;
|
||||
return [];
|
||||
return ResponsePlanToSocketMessagesMapper.MapNoInput(
|
||||
turnState.TransId ?? session.LastTransId ?? string.Empty,
|
||||
turnState.ListenRules)
|
||||
.Select(map => new WebSocketReply
|
||||
{
|
||||
Text = map.Text,
|
||||
DelayMs = map.DelayMs
|
||||
})
|
||||
.ToArray();
|
||||
}
|
||||
|
||||
if (ShouldIgnoreInitialEmptyHotphraseTurn(finalizedTurn, turnState))
|
||||
|
||||
Reference in New Issue
Block a user