mirror of
https://kevinblog.sytes.net/Code/Jibo-Revival-Group/JiboExperiments.git
synced 2026-06-16 21:16:28 +00:00
Add support voice routes and short-answer STT handling
This commit is contained in:
@@ -190,6 +190,29 @@ public sealed class LegacyMimCatalogImporterTests
|
||||
reply.Contains("north Pole", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImportCatalog_ImportsBuildBSupportResponsesIntoDedicatedBuckets()
|
||||
{
|
||||
var rootDirectory = Path.Combine(
|
||||
AppContext.BaseDirectory,
|
||||
"Content",
|
||||
"LegacyMims",
|
||||
"BuildB");
|
||||
|
||||
var catalog = LegacyMimCatalogImporter.ImportCatalog(rootDirectory);
|
||||
|
||||
Assert.Contains(catalog.BackupHowReplies, reply =>
|
||||
reply.Contains("Help section of the Jibo App", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.RestoreHowReplies, reply =>
|
||||
reply.Contains("Jibo Customer Care", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.UpdateNextReplies, reply =>
|
||||
reply.Contains("coming every few weeks", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.UpdateNextReplies, reply =>
|
||||
reply.Contains("pretty regularly", StringComparison.OrdinalIgnoreCase));
|
||||
Assert.Contains(catalog.UpdateLastReplies, reply =>
|
||||
reply.Contains("release notes page", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ImportCatalog_ImportsBuildBFriendshipResponsesIntoFriendBuckets()
|
||||
{
|
||||
|
||||
@@ -712,6 +712,29 @@ public sealed class JiboInteractionServiceTests
|
||||
Assert.Equal("ScriptedResponse", decision.ContextUpdates![ChitchatRouteKey]);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("can i backup my jibo", "backup_help", "Help section of the Jibo App")]
|
||||
[InlineData("how can i restore you from a backup", "restore_backup", "Jibo Customer Care")]
|
||||
[InlineData("when is your next update", "update_next", "coming every few weeks")]
|
||||
[InlineData("when was your last update", "update_last", "release notes page")]
|
||||
public async Task BuildDecisionAsync_SupportHelpQuestions_UseImportedReplies(
|
||||
string transcript,
|
||||
string expectedIntent,
|
||||
string expectedReplySnippet)
|
||||
{
|
||||
var service = CreateService();
|
||||
|
||||
var decision = await service.BuildDecisionAsync(new TurnContext
|
||||
{
|
||||
RawTranscript = transcript,
|
||||
NormalizedTranscript = transcript
|
||||
});
|
||||
|
||||
Assert.Equal(expectedIntent, decision.IntentName);
|
||||
Assert.Contains(expectedReplySnippet, decision.ReplyText, StringComparison.OrdinalIgnoreCase);
|
||||
Assert.Equal("ScriptedResponse", decision.ContextUpdates![ChitchatRouteKey]);
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("what do you want to talk about", "robot_want_to_talk_about", "surprise me")]
|
||||
[InlineData("what would you like to talk about", "robot_want_to_talk_about", "surprise me")]
|
||||
|
||||
@@ -102,6 +102,34 @@ public sealed class LocalWhisperCppBufferedAudioSttStrategyTests
|
||||
Assert.False(strategy.CanHandle(turn));
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("shared/yes_no")]
|
||||
[InlineData("word-of-the-day/surprise")]
|
||||
public void CanHandle_ReturnsTrue_WhenShortAnswerTurnsStayUnderTheStandardNoiseFloor(string listenRule)
|
||||
{
|
||||
var strategy = new LocalWhisperCppBufferedAudioSttStrategy(
|
||||
new BufferedAudioSttOptions
|
||||
{
|
||||
EnableLocalWhisperCpp = true,
|
||||
FfmpegPath = "ffmpeg",
|
||||
WhisperCliPath = "whisper-cli",
|
||||
WhisperModelPath = "model.bin"
|
||||
},
|
||||
new FakeExternalProcessRunner());
|
||||
|
||||
var turn = new TurnContext
|
||||
{
|
||||
Attributes = new Dictionary<string, object?>
|
||||
{
|
||||
["bufferedAudioBytes"] = 47,
|
||||
["bufferedAudioFrames"] = new[] { BuildMinimalOggPage() },
|
||||
["listenRules"] = new[] { listenRule }
|
||||
}
|
||||
};
|
||||
|
||||
Assert.True(strategy.CanHandle(turn));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TranscribeAsync_UsesFfmpegAndWhisperCpp_WhenConfigured()
|
||||
{
|
||||
@@ -148,6 +176,54 @@ public sealed class LocalWhisperCppBufferedAudioSttStrategyTests
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("shared/yes_no")]
|
||||
[InlineData("word-of-the-day/surprise")]
|
||||
public async Task TranscribeAsync_HandlesShortAnswerTurnsWithoutHittingTheStandardNoiseFloor(string listenRule)
|
||||
{
|
||||
var tempDirectory = Path.Combine(Path.GetTempPath(), $"openjibo-stt-test-{Guid.NewGuid():N}");
|
||||
Directory.CreateDirectory(tempDirectory);
|
||||
|
||||
try
|
||||
{
|
||||
var runner = new FakeExternalProcessRunner("[00:00:00.000 --> 00:00:01.000] yes.");
|
||||
var strategy = new LocalWhisperCppBufferedAudioSttStrategy(
|
||||
new BufferedAudioSttOptions
|
||||
{
|
||||
EnableLocalWhisperCpp = true,
|
||||
FfmpegPath = "ffmpeg",
|
||||
WhisperCliPath = "whisper-cli",
|
||||
WhisperModelPath = "model.bin",
|
||||
TempDirectory = tempDirectory
|
||||
},
|
||||
runner);
|
||||
|
||||
var turn = new TurnContext
|
||||
{
|
||||
TurnId = listenRule == "shared/yes_no"
|
||||
? "turn-short-yes-no"
|
||||
: "turn-short-word-of-the-day",
|
||||
Locale = "en-US",
|
||||
Attributes = new Dictionary<string, object?>
|
||||
{
|
||||
["bufferedAudioBytes"] = 47,
|
||||
["bufferedAudioFrames"] = new[] { BuildMinimalOggPage() },
|
||||
["listenRules"] = new[] { listenRule }
|
||||
}
|
||||
};
|
||||
|
||||
var result = await strategy.TranscribeAsync(turn);
|
||||
|
||||
Assert.Equal("yes", result.Text);
|
||||
Assert.Equal("local-whispercpp-buffered-audio", result.Provider);
|
||||
Assert.Equal(2, runner.Calls.Count);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (Directory.Exists(tempDirectory)) Directory.Delete(tempDirectory, true);
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task TranscribeAsync_NormalizesLoosePunctuationFromWhisperOutput()
|
||||
{
|
||||
@@ -275,4 +351,4 @@ public sealed class LocalWhisperCppBufferedAudioSttStrategyTests
|
||||
return Task.FromResult(new ExternalProcessResult(0, string.Empty, string.Empty));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user