Exemple #1
0
        public static void RandomPartySound()
        {
            Random rdm   = new Random();
            var    files = GetPartyFiles();

            var index = rdm.Next(files.Length);

            SpeakerCore.ExecuteMP3File(files[index]);
        }
Exemple #2
0
        public static void Xandao()
        {
            var files = GetGeneralFiles();
            var piada = files.Where(q => q.Contains("xandao.mp3")).FirstOrDefault();

            if (piada != null)
            {
                SpeakerCore.ExecuteMP3File(piada);
            }
        }
        private static async Task SpeakGoogle(ISpeaker speaker, string textToSpeech, string user)
        {
            textToSpeech = textToSpeech.Replace("\"", "\"\"");

            // Instantiate a client
            TextToSpeechClient client = TextToSpeechClient.Create();

            // Set the text input to be synthesized.
            SynthesisInput input = new SynthesisInput
            {
            //Text = textToSpeech,
                Ssml = File.ReadAllText("Speakers/SSML.xml").Replace("{text}", textToSpeech).Replace("{voice}", speaker.Voice).Replace("{posmsg}", speaker.Diction).Replace("{alert}", speaker.Alert),
            };

            // Build the voice request, select the language code ("en-US"),
            // and the SSML voice gender ("neutral").
            VoiceSelectionParams voice = new VoiceSelectionParams
            {
                LanguageCode = speaker.Accent.ToString(),
                //SsmlGender = SsmlVoiceGender.Neutral
            };

            // Select the type of audio file you want returned.
            AudioConfig config = new AudioConfig
            {
                AudioEncoding = AudioEncoding.Mp3
            };

            // Perform the Text-to-Speech request, passing the text input
            // with the selected voice parameters and audio file type
            var response = await client.SynthesizeSpeechAsync(new SynthesizeSpeechRequest
            {
                Input = input,
                Voice = voice,
                AudioConfig = config
            });

            // create a temp file with .ps1 extension  
            var cFile = System.IO.Path.GetTempPath() + Guid.NewGuid() + ".mp3";

            // Write the binary AudioContent of the response to an MP3 file.
            using (Stream output = File.Create(cFile))
                response.AudioContent.WriteTo(output);

            Sounds.RandomTrollSound();

            SpeakerCore.PreSpeech(user);

            SpeakerCore.ExecuteMP3File(cFile);

            await AutomaticTranslator.Translate(textToSpeech);

        }
Exemple #4
0
        public static void RandomTrollSound()
        {
            if (!CheckStatus())
            {
                return;
            }

            Random rdm   = new Random();
            var    files = GetTrollFiles();

            var index = rdm.Next(files.Length);

            SpeakerCore.ExecuteMP3File(files[index]);
            //Task.Delay(500);
        }