public static async Task Speak(string textToSpeech, string user,Languages lang) { if (!await SpeakerCore.CheckStatus() || Parameters.GoogleTranslateApiKey == null) return; Speaker spk = Speakers.FirstOrDefault(q => q.Language == lang); if (spk != null) await SpeakGoogle(spk, textToSpeech, user); }
public static void RandomPartySound() { Random rdm = new Random(); var files = GetPartyFiles(); var index = rdm.Next(files.Length); SpeakerCore.ExecuteMP3File(files[index]); }
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); }
public static async Task Speak(string textToSpeech, string user, Languages lang) { if (!await SpeakerCore.CheckStatus() || config == null) { return; } Speaker spk = Speakers.FirstOrDefault(q => q.Language == lang); if (spk != null) { await SpeakAzure(spk, textToSpeech, user); } }
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); }
private static async Task SpeakAzure(ISpeaker speaker, string textToSpeech, string user) { textToSpeech = textToSpeech.Replace("\"", "\"\""); config.SpeechSynthesisVoiceName = speaker.Voice; using var synthesizer = new SpeechSynthesizer(config); var ssml = File.ReadAllText("Speakers/SSML.xml").Replace("{text}", textToSpeech).Replace("{voice}", speaker.Voice).Replace("{posmsg}", speaker.Diction).Replace("{alert}", speaker.Alert); SpeakerCore.PreSpeech(user); var result = await synthesizer.SpeakSsmlAsync(ssml); await AutomaticTranslator.Translate(textToSpeech); }
public static async Task CheckNotice(string input) { string[] properties = input.Split(";"); var loginPropert = properties.First(q => q.StartsWith("login="******"=")[1]; //raider é o cidadão q está enviando a raid pra vc if (input.Contains("msg-id=raid;")) { await TasksQueueOutput.QueueAddSpeech(async() => { await AudioVisual.Party("", Parameters.User); await SpeakerCore.Speak("Muito obrigado, " + raider + ". Você é um Deus...", Parameters.User); }); } }