Esempio n. 1
0
        private async Task Say(IAudioClient connection, FalopaSound sound)
        {
            try
            {
                await connection.SetSpeakingAsync(true); // send a speaking indicator

                var psi = new ProcessStartInfo
                {
                    FileName  = @"F:\Source\FalopaBot\FalopaBot.Lib\Modules\ffmpeg.exe",
                    Arguments = $@"-i ""{sound.Filename}"" -ac 2 -f s16le -ar 48000 pipe:1",
                    RedirectStandardOutput = true,
                    UseShellExecute        = false
                };
                var ffmpeg = Process.Start(psi);

                var output  = ffmpeg.StandardOutput.BaseStream;
                var discord = connection.CreatePCMStream(AudioApplication.Voice);
                await output.CopyToAsync(discord);

                await discord.FlushAsync();

                await connection.SetSpeakingAsync(false); // we're not speaking anymore
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine($"- {ex.StackTrace}");
            }
        }
Esempio n. 2
0
 private async Task RandomSound(IAudioClient connection)
 {
     await Say(connection, FalopaSound.RandomSound());
 }