diff --git a/PluginSpeech/AssemblyInfo.cs b/PluginSpeech/AssemblyInfo.cs deleted file mode 100644 index ac87e62..0000000 --- a/PluginSpeech/AssemblyInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; - -[assembly: AssemblyCopyright("© 2019 - Jeffrey Morley")] -[assembly: AssemblyVersion("2.3.0.0")] - -// Do not change the entries below! -#if X64 -[assembly: AssemblyInformationalVersion("4.2.0.3111 (64-bit)")] -#else -[assembly: AssemblyInformationalVersion("4.2.0.3111 (32-bit)")] -#endif -[assembly: AssemblyProduct("Rainmeter")] diff --git a/PluginSpeech/PluginSpeech.cs b/PluginSpeech/PluginSpeech.cs deleted file mode 100644 index 0852cdd..0000000 --- a/PluginSpeech/PluginSpeech.cs +++ /dev/null @@ -1,236 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Runtime.InteropServices; -using System.Speech.Synthesis; -using System.Threading; -using Rainmeter; - -namespace PluginSpeech -{ - class Measure - { - static public implicit operator Measure(IntPtr data) - { - return (Measure)GCHandle.FromIntPtr(data).Target; - } - public IntPtr buffer = IntPtr.Zero; - public SpeechSynthesizer synth; - public VoiceGender gender; - public int index; - public Prompt prompt; - public String selectedName; - public double voiceCount; - } - - public class Plugin - { - [DllExport] - public static void Initialize(ref IntPtr data, IntPtr rm) - { - data = GCHandle.ToIntPtr(GCHandle.Alloc(new Measure())); - Rainmeter.API api = (Rainmeter.API)rm; - - Measure measure = (Measure)data; - measure.synth = new SpeechSynthesizer(); - measure.prompt = new Prompt(""); - - measure.voiceCount = 0.0; - foreach (InstalledVoice voice in measure.synth.GetInstalledVoices()) - { - measure.voiceCount++; - } - - measure.synth.SetOutputToDefaultAudioDevice(); - } - - [DllExport] - public static void Finalize(IntPtr data) - { - Measure measure = (Measure)data; - - if (!measure.prompt.IsCompleted) - { - measure.synth.SpeakAsyncCancelAll(); - } - - measure.synth.Dispose(); - - if (measure.buffer != IntPtr.Zero) - { - Marshal.FreeHGlobal(measure.buffer); - } - GCHandle.FromIntPtr(data).Free(); - } - - [DllExport] - public static void Reload(IntPtr data, IntPtr rm, ref double maxValue) - { - Measure measure = (Measure)data; - Rainmeter.API api = (Rainmeter.API)rm; - - string name = api.ReadString("Name", ""); - bool nameExists = name != "" ? true : false; - - VoiceGender gender = VoiceGender.NotSet; - string genderStr = api.ReadString("Gender", "").ToUpper(); - if (genderStr == "MALE") - { - gender = VoiceGender.Male; - } - else if (genderStr == "FEMALE") - { - gender = VoiceGender.Female; - } - else if (genderStr != "") - { - api.Log(API.LogType.Warning, "Speech.dll: Invalid gender"); - } - bool genderExists = gender != VoiceGender.NotSet; - measure.gender = gender; - - int index = api.ReadInt("Index", 0); - measure.index = index; - - int volume = api.ReadInt("Volume", 100); - if (volume < 0 || volume > 100) - { - volume = 100; - } - - int rate = api.ReadInt("Rate", 0); - if (rate < -10 || rate > 10) - { - rate = 0; - } - - measure.synth.Volume = volume; - measure.synth.Rate = rate; - - // Setup voice - int i = 1; - String selectedName = ""; - - foreach (InstalledVoice voice in measure.synth.GetInstalledVoices()) - { - // If no options are "defined", use the first voice. - if (!nameExists && !genderExists && (index <= 0)) - { - selectedName = voice.VoiceInfo.Name; - break; - } - - // If name is defined, use this voice. - if (nameExists && (name.ToUpper() == voice.VoiceInfo.Name.ToUpper())) - { - selectedName = voice.VoiceInfo.Name; - break; - } - - // If gender is defined, only look for voices of the same gender - if (!nameExists && genderExists) - { - if (gender != voice.VoiceInfo.Gender) continue; - - if (index > 0) - { - if (index == i) - { - selectedName = voice.VoiceInfo.Name; - break; - } - - ++i; - continue; - } - else - { - selectedName = voice.VoiceInfo.Name; - break; - } - } - - // Select by index - if (!nameExists && index == i) - { - selectedName = voice.VoiceInfo.Name; - break; - } - - ++i; - } - - measure.selectedName = selectedName; - - // Something went wrong - // Name is incorrect - // No matching gender was found - // Invalid index - if (selectedName == "") - { - api.Log(API.LogType.Warning, "Speech.dll: Invalid Name, Gender and/or Index. Using best matching valid voice."); - } - } - - [DllExport] - public static double Update(IntPtr data) - { - Measure measure = (Measure)data; - - return measure.voiceCount; - } - - [DllExport] - public static void ExecuteBang(IntPtr data, [MarshalAs(UnmanagedType.LPWStr)]String args) - { - Measure measure = (Measure)data; - - if (!measure.prompt.IsCompleted) - { - measure.synth.SpeakAsyncCancelAll(); - Thread.Sleep(10); - } - - if (measure.selectedName == "") - { - measure.synth.SelectVoiceByHints(measure.gender, VoiceAge.NotSet, measure.index); - } - else - { - measure.synth.SelectVoice(measure.selectedName); - } - - measure.prompt = measure.synth.SpeakAsync(args); - } - - [DllExport] - public static IntPtr GetString(IntPtr data) - { - Measure measure = (Measure)data; - if (measure.buffer != IntPtr.Zero) - { - Marshal.FreeHGlobal(measure.buffer); - measure.buffer = IntPtr.Zero; - } - - measure.buffer = Marshal.StringToHGlobalUni(measure.selectedName); - - return measure.buffer; - } - - //[DllExport] - //public static IntPtr (IntPtr data, int argc, - // [MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 1)] string[] argv) - //{ - // Measure measure = (Measure)data; - // if (measure.buffer != IntPtr.Zero) - // { - // Marshal.FreeHGlobal(measure.buffer); - // measure.buffer = IntPtr.Zero; - // } - // - // measure.buffer = Marshal.StringToHGlobalUni(""); - // - // return measure.buffer; - //} - } -} diff --git a/PluginSpeech/PluginSpeech.csproj b/PluginSpeech/PluginSpeech.csproj deleted file mode 100644 index 5d711ac..0000000 --- a/PluginSpeech/PluginSpeech.csproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - Debug - x86 - 9.0.30729 - 2.0 - {292019B4-B5CA-4959-BB72-6C3667D812D4} - Library - Properties - PluginSpeech - Speech - v3.5 - 512 - 3.5 - - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - - true - full - false - x32\Debug\ - TRACE;DEBUG - true - prompt - 4 - 1607 - x86 - - - none - true - x32\Release\ - TRACE - true - prompt - 4 - 1607 - x86 - - - true - x64\Debug\ - TRACE;DEBUG;X64 - true - full - x64 - prompt - 1607 - - - x64\Release\ - TRACE;X64 - true - true - none - x64 - prompt - 1607 - - - Always - - - - - - - - - - - - - - "$(SolutionDir)..\API\DllExporter.exe" "$(ConfigurationName)" "$(PlatformName)" "$(TargetDir)\" "$(TargetFileName)" - - \ No newline at end of file