RoboZhando/Synthesizer.cs
/// <summary>Creates a speakable message from the given discord message</summary>
Creates a speakable message from the given discord message
Creates a speakable message from the given discord message
protected async Task<string> CreateSSMLMessage(DiscordMessage message)
        {
            string text = await CreateCleanMessage(message);
            if (string.IsNullOrWhiteSpace(text)) return null;
            string voice = await GetPreferedVoice(message.Author);
            string speak = SSML_SPEAK_TEMPLATE.Replace("{voice}", voice).Replace("{message}", text);
            if (!string.IsNullOrEmpty(AnouncerVoice))
            {
                string author = message.Author.Username;
                if (message.Channel?.Guild != null) {
                    var member = await message.Channel.Guild.GetMemberAsync(message.Author.Id);
                    if (member != null) 
                        author = member.DisplayName;
                }
                var additionalSpeak = SSML_SPEAK_TEMPLATE.Replace("{voice}", AnouncerVoice).Replace("{message}", $"{author} says");
                speak = additionalSpeak + speak;
            }
            return SSML_TEMPLATE.Replace("{speak}", speak);
        }
protected async Task < string > CreateSSMLMessage ( DiscordMessage message ) { string text = await CreateCleanMessage ( message ) ; if ( string . IsNullOrWhiteSpace ( text ) ) return null ; string voice = await GetPreferedVoice ( message . Author ) ; string speak = SSML_SPEAK_TEMPLATE . Replace ( " " , voice ) . Replace ( " " , text ) ; if ( ! string . IsNullOrEmpty ( AnouncerVoice ) ) { string author = message . Author . Username ; if ( message . Channel ? . Guild != null ) { var member = await message . Channel . Guild . GetMemberAsync ( message . Author . Id ) ; if ( member != null ) author = member . DisplayName ; } var additionalSpeak = SSML_SPEAK_TEMPLATE . Replace ( " " , AnouncerVoice ) . Replace ( " " , $" { author }  says " ) ; speak = additionalSpeak + speak ; } return SSML_TEMPLATE . Replace ( " " , speak ) ; }
Creates a speakable message from the given discord message
Creates a speakable message from the given discord message
// Generate the message // Add the "Author Says" // Get the author name // Create the new speak and append it to the end // Return the combined speak
message
DiscordMessage