// Clear all clips in a tts preload file public static void DeleteData(TTSService service) { // Get test file path string path = service.GetDiskCachePath(string.Empty, "TEST", null, new TTSDiskCacheSettings() { DiskCacheLocation = TTSDiskCacheLocation.Preload }); // Get directory string directory = new FileInfo(path).DirectoryName; if (!Directory.Exists(directory)) { return; } // Ask if (!EditorUtility.DisplayDialog("Delete Preload Cache", $"Are you sure you would like to delete the TTS Preload directory at:\n{directory}?", "Okay", "Cancel")) { return; } // Delete recursively Directory.Delete(directory, true); // Delete meta string meta = directory + ".meta"; if (File.Exists(meta)) { File.Delete(meta); } // Refresh assets AssetDatabase.Refresh(); }
// Refresh phrase data public static void RefreshPhraseData(TTSService service, TTSDiskCacheSettings cacheSettings, TTSVoiceSettings voiceSettings, TTSPreloadPhraseData phraseData) { // Get voice settings if (service == null || voiceSettings == null || string.IsNullOrEmpty(phraseData.textToSpeak)) { phraseData.clipID = string.Empty; phraseData.downloaded = false; phraseData.downloadProgress = 0f; return; } if (cacheSettings == null) { cacheSettings = new TTSDiskCacheSettings() { DiskCacheLocation = TTSDiskCacheLocation.Preload }; } // Get phrase data phraseData.clipID = service.GetClipID(phraseData.textToSpeak, voiceSettings); // Check if file exists string path = service.GetDiskCachePath(phraseData.textToSpeak, phraseData.clipID, voiceSettings, cacheSettings); phraseData.downloaded = File.Exists(path); phraseData.downloadProgress = phraseData.downloaded ? 1f : 0f; }