Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of DectalkTTS v1.0.1
DectalkTTS.dll
Decompiled a year agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Strobotnik.Klattersynth; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("DectalkTTS")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DectalkTTS")] [assembly: AssemblyTitle("DectalkTTS")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DectalkTTS { [BepInPlugin("DectalkTTS", "DectalkTTS", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin DectalkTTS is loaded!"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "DectalkTTS"; public const string PLUGIN_NAME = "DectalkTTS"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace TestProject { internal class DecTalk { private static string dictionaryPath; [DllImport("dectalk.dll")] public static extern int TextToSpeechStartup(IntPtr HWND, ref IntPtr phTTS, ushort uiDeviceNumber, uint dwDeviceOptions); [DllImport("dectalk.dll")] public static extern int TextToSpeechStartupExFonix(ref IntPtr phTTS, ushort uiDeviceNumber, uint dwDeviceOptions, IntPtr callback, int _, [MarshalAs(UnmanagedType.LPStr)] string dictionaryFilename); [DllImport("dectalk.dll")] public static extern int TextToSpeechOpenWaveOutFile(IntPtr phTTS, [MarshalAs(UnmanagedType.LPStr)] string filename, uint format); [DllImport("dectalk.dll")] public static extern int TextToSpeechSpeak(IntPtr phTTS, [MarshalAs(UnmanagedType.LPStr)] string text, uint flags); [DllImport("dectalk.dll")] public static extern int TextToSpeechCloseWaveOutFile(IntPtr phTTS); [DllImport("dectalk.dll")] public static extern int TextToSpeechShutdown(IntPtr phTTS); public static void say(string text, string filename) { IntPtr phTTS = default(IntPtr); if (dictionaryPath == null) { dictionaryPath = Directory.EnumerateFiles(Paths.PluginPath, "dtalk_us.dic", SearchOption.AllDirectories).First(); } int num = TextToSpeechStartupExFonix(ref phTTS, 0, 2281701376u, IntPtr.Zero, 0, dictionaryPath); num = TextToSpeechOpenWaveOutFile(phTTS, filename, 4u); num = TextToSpeechSpeak(phTTS, text, 1u); num = TextToSpeechCloseWaveOutFile(phTTS); TextToSpeechShutdown(phTTS); } } [HarmonyPatch(typeof(SpeechSynth))] [HarmonyPatch("speak")] [HarmonyPatch(new Type[] { typeof(StringBuilder), typeof(int), typeof(VoicingSource), typeof(bool) })] internal class Patch { private static void Postfix(SpeechSynth __instance, StringBuilder text) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown string text2 = Path.GetTempPath() + Guid.NewGuid().ToString() + ".wav"; try { DecTalk.say(text.ToString(), text2); UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(text2, (AudioType)20); UnityWebRequestAsyncOperation val = audioClip.SendWebRequest(); while (!((AsyncOperation)val).isDone) { } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); AudioSource val2 = (AudioSource)typeof(SpeechSynth).GetField("af", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(__instance); typeof(SpeechSynth).GetField("l", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).SetValue(__instance, content.samples); val2.clip = content; val2.loop = false; val2.Play(); } finally { if (File.Exists(text2)) { File.Delete(text2); } } } } }