Browse Source

[RECOMPILE] Added Debug Wipe last cached/played audio clip

master
Tillman Staffen 1 month ago
parent
commit
da0224a338
  1. BIN
      Unreal/Plugins/AvatarCore_Manager/Content/Widgets/Debug/Pages/W_DebugAvatarCoreTTS.uasset
  2. 40
      Unreal/Plugins/AvatarCore_TTS/Source/AvatarCore_TTS/Private/TTSManagerBase.cpp
  3. 6
      Unreal/Plugins/AvatarCore_TTS/Source/AvatarCore_TTS/Public/TTSManagerBase.h

BIN
Unreal/Plugins/AvatarCore_Manager/Content/Widgets/Debug/Pages/W_DebugAvatarCoreTTS.uasset (Stored with Git LFS)

Binary file not shown.

40
Unreal/Plugins/AvatarCore_TTS/Source/AvatarCore_TTS/Private/TTSManagerBase.cpp

@ -298,6 +298,46 @@ void UTTSManagerBase::WipeCache()
}
}
void UTTSManagerBase::WipeLastCachedFile()
{
IPlatformFile& PlatformFile = FPlatformFileManager::Get().GetPlatformFile();
FString CacheDir = GetCacheDirectory();
if (!PlatformFile.DirectoryExists(*CacheDir))
{
UE_LOG(LogTemp, Warning, TEXT("Directory does not exist: %s - Cache disable?"), *CacheDir);
return;
}
TArray<FString> FileNames;
const FString Wildcard = FPaths::Combine(CacheDir, TEXT("*"));
IFileManager::Get().FindFiles(FileNames, *Wildcard, /*Files=*/true, /*Directories=*/false);
if (FileNames.Num() == 0)
{
UE_LOG(LogTemp, Warning, TEXT("No files in dir: %s - Cache disable?"), *CacheDir);
return;
}
FDateTime NewestTimestamp = FDateTime::MinValue();
FString NewestFullPath;
for (const FString& FileName : FileNames)
{
const FString FullPath = FPaths::Combine(CacheDir, FileName);
const FDateTime Timestamp = IFileManager::Get().GetTimeStamp(*FullPath);
if (Timestamp > NewestTimestamp)
{
NewestTimestamp = Timestamp;
NewestFullPath = FullPath;
}
}
if (!NewestFullPath.IsEmpty() && PlatformFile.FileExists(*NewestFullPath))
{
IFileManager::Get().Delete(*NewestFullPath, /*RequireExists=*/false, /*EvenReadOnly=*/true, /*Quiet=*/true);
UE_LOG(LogTemp, Warning, TEXT("File deleted: %s"), *NewestFullPath);
}
}
void UTTSManagerBase::OnTTSManagerFinished()
{
// Reset procedural sound wave

6
Unreal/Plugins/AvatarCore_TTS/Source/AvatarCore_TTS/Public/TTSManagerBase.h

@ -158,10 +158,14 @@ public:
UFUNCTION(BlueprintCallable, Category = "AvatarCoreTTS|Cache")
void PreCacheSpeeches(TArray<FString> Sentences);
// Wipe the complete audio cache - latest played audio clip will always have the latest change date on disk (if you want to delete audio more surgically)
// Wipe the complete audio cache
UFUNCTION(BlueprintCallable, Category = "AvatarCoreTTS|Cache")
static void WipeCache();
// Delete the last played/cached audio file
UFUNCTION(BlueprintCallable, Category = "AvatarCoreTTS|Cache")
void WipeLastCachedFile();
// Manager has finished what he was doing
void OnTTSManagerFinished();

Loading…
Cancel
Save