예제 #1
0
        private static void ProcessArgs(Options opts)
        {
            if (opts.Minimise)
            {
                MinimizeConsoleWindow();
            }

            //process freqs
            var freqStr = opts.Freqs.Split(',');

            List <double> freqDouble = new List <double>();

            foreach (var s in freqStr)
            {
                freqDouble.Add(double.Parse(s, CultureInfo.InvariantCulture) * 1000000d);
            }

            var modulationStr = opts.Modulations.Split(',');

            List <RadioInformation.Modulation> modulation = new List <RadioInformation.Modulation>();

            foreach (var s in modulationStr)
            {
                RadioInformation.Modulation mod;
                if (RadioInformation.Modulation.TryParse(s.Trim().ToUpper(), out mod))
                {
                    modulation.Add(mod);
                }
            }

            if (modulation.Count != freqDouble.Count)
            {
                Console.WriteLine($"Number of frequencies ({freqDouble.Count}) does not match number of modulations ({modulation.Count}) - They must match!" +
                                  $"\n\nFor example: --freq=251.0,252.0 --modulations=AM,AM ");
                Console.WriteLine("QUITTING!");
            }

            ExternalAudioClient client = new ExternalAudioClient(freqDouble.ToArray(), modulation.ToArray(), opts);

            client.Start();
        }
예제 #2
0
        public static void Main(string[] args)
        {
            if (args.Length != 7)
            {
                Console.WriteLine("Error incorrect parameters - should be path or text frequency modulation coalition port name volume");
                Console.WriteLine("Example: \"C:\\FULL\\PATH\\TO\\File.mp3\" 251.0 AM 1 5002 ciribob-robot 0.5");
                Console.WriteLine("Example: \"I want this read out over this frequency - hello world! \" 251.0 AM 1 5002 ciribob-robot 0.5");
                Console.WriteLine("Example: \"I want this read out over TWO frequencies - hello world! \" 251.0,252.0 AM,AM 1 5002 ciribob-robot 0.5");
                Console.WriteLine("Path or Text - either a full path ending with .mp3 or text to read out");
                Console.WriteLine("Frequency in MHz comma separated - 251.0,252.0 or just 252.0  ");
                Console.WriteLine("Modulation AM or FM comma separated - AM,FM or just AM  ");
                Console.WriteLine("Coalition - 0 is Spectator, 1 is Red, 2 is Blue");
                Console.WriteLine("Port - 5002 is the default");
                Console.WriteLine("Name - name of your transmitter - no spaces");
                Console.WriteLine("Volume - 1.0 is max, 0.0 is silence");
            }
            else
            {
                ConfigureLogging();

                string mp3         = args[0].Trim();
                string freqs       = args[1].Trim();
                string modulations = args[2].Trim().ToUpperInvariant();
                int    coalition   = int.Parse(args[3].Trim());
                int    port        = int.Parse(args[4].Trim());
                string name        = args[5].Trim();
                float  volume      = float.Parse(args[6].Trim(), CultureInfo.InvariantCulture);

                //process freqs
                var freqStr = freqs.Split(',');

                List <double> freqDouble = new List <double>();
                foreach (var s in freqStr)
                {
                    freqDouble.Add(double.Parse(s, CultureInfo.InvariantCulture) * 1000000d);
                }

                var modulationStr = modulations.Split(',');

                List <RadioInformation.Modulation> modulation = new List <RadioInformation.Modulation>();
                foreach (var s in modulationStr)
                {
                    RadioInformation.Modulation mod;
                    if (RadioInformation.Modulation.TryParse(s.Trim().ToUpper(), out mod))
                    {
                        modulation.Add(mod);
                    }
                }

                if (modulation.Count != freqDouble.Count)
                {
                    Console.WriteLine($"Number of frequencies ({freqDouble.Count}) does not match number of modulations ({modulation.Count}) - They must match!" +
                                      $"\n\nFor example: 251.0,252.0 AM,AM ");
                    Console.WriteLine("QUITTING!");
                }
                else
                {
                    ExternalAudioClient client = new ExternalAudioClient(mp3, freqDouble.ToArray(), modulation.ToArray(), coalition, port, name, volume);
                    client.Start();
                }
            }
        }
예제 #3
0
        public static void Main(string[] args)
        {
            if ((args.Length < 7) || (args.Length > 9))
            {
                CultureInfo[] Cultures          = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
                string        availableCultures = "";
                var           synthesizer       = new SpeechSynthesizer();
                foreach (var voice in synthesizer.GetInstalledVoices())
                {
                    var info = voice.VoiceInfo;
                    availableCultures += info.Culture + "/" + info.Gender + " ";
                }

                Console.WriteLine("Error incorrect parameters - should be path or text frequency modulation coalition port name volume");
                Console.WriteLine("Example: \"C:\\FULL\\PATH\\TO\\File.mp3\" 251.0 AM 1 5002 ciribob-robot 0.5");
                Console.WriteLine("Example: \"I want this read out over this frequency - hello world! \" 251.0 AM 1 5002 ciribob-robot 0.5");
                Console.WriteLine("Example: \"I want this read out over TWO frequencies - hello world! \" 251.0,252.0 AM,AM 1 5002 ciribob-robot 0.5");
                Console.WriteLine("Path or Text - either a full path ending with .mp3 or text to read out");
                Console.WriteLine("Frequency in MHz comma separated - 251.0,252.0 or just 252.0  ");
                Console.WriteLine("Modulation AM or FM comma separated - AM,FM or just AM  ");
                Console.WriteLine("Coalition - 0 is Spectator, 1 is Red, 2 is Blue");
                Console.WriteLine("Port - 5002 is the default");
                Console.WriteLine("Name - name of your transmitter - no spaces");
                Console.WriteLine("Volume - 1.0 is max, 0.0 is silence");
                Console.WriteLine("(optional) TTS Gender - male/female");
                Console.WriteLine("(optional) TTS culture - local for the voice");
                Console.WriteLine("currently installed Voices on this system: " + availableCultures);
            }
            else
            {
                ConfigureLogging();

                string mp3         = args[0].Trim();
                string freqs       = args[1].Trim();
                string modulations = args[2].Trim().ToUpperInvariant();
                int    coalition   = int.Parse(args[3].Trim());
                int    port        = int.Parse(args[4].Trim());
                string name        = args[5].Trim();
                float  volume      = float.Parse(args[6].Trim(), CultureInfo.InvariantCulture);
                string gender      = "female";
                string culture     = "en-GB";
                if (args.Length > 7)
                {
                    gender = args[7].Trim().ToLowerInvariant();
                }
                if (args.Length == 9)
                {
                    culture = args[8].Trim();
                }

                //process freqs
                var freqStr = freqs.Split(',');

                List <double> freqDouble = new List <double>();
                foreach (var s in freqStr)
                {
                    freqDouble.Add(double.Parse(s, CultureInfo.InvariantCulture) * 1000000d);
                }

                var modulationStr = modulations.Split(',');

                List <RadioInformation.Modulation> modulation = new List <RadioInformation.Modulation>();
                foreach (var s in modulationStr)
                {
                    RadioInformation.Modulation mod;
                    if (RadioInformation.Modulation.TryParse(s.Trim().ToUpper(), out mod))
                    {
                        modulation.Add(mod);
                    }
                }

                if (modulation.Count != freqDouble.Count)
                {
                    Console.WriteLine($"Number of frequencies ({freqDouble.Count}) does not match number of modulations ({modulation.Count}) - They must match!" +
                                      $"\n\nFor example: 251.0,252.0 AM,AM ");
                    Console.WriteLine("QUITTING!");
                }
                else
                {
                    ExternalAudioClient client = new ExternalAudioClient(mp3, freqDouble.ToArray(), modulation.ToArray(), coalition, port, name, volume, gender, culture);
                    client.Start();
                }
            }
        }