Beispiel #1
0
        public static void TextToSpeech([DI] SocketMessage msg, string src)
        {
            byte[] bytes;
            string lang;
            int    idx = src.IndexOf(' ');

            if (idx > 0 && idx != src.Length - 1 && GoogleTranslate.SupportsLanguage(lang = src.Substring(0, idx)))
            {
                bytes = GoogleTranslate.TextToSpeech(src.Substring(idx + 1), lang).Result;
            }
            else
            {
                bytes = GoogleTranslate.TextToSpeech(src).Result;
            }

            msg.Channel.SendFileAsync(new MemoryStream(bytes), "audio.mp3").Wait();
        }