C#3.0基于Speech.Synthesis调整语音朗读语调范例

using System;
using System.Speech.Synthesis;

namespace Speech_Synthesis
{
    public partial class Window1 : System.Windows.Window
    {
        public Window1()
        {
            InitializeComponent();

            SpeechSynthesizer synthesizer = new SpeechSynthesizer();
            PromptBuilder promptBuilder = new PromptBuilder();

            promptBuilder.AppendTextWithHint("尹成", SayAs.SpellOut);
            promptBuilder.AppendText("尹成大哥毕业于山东大学.");

           
            promptBuilder.AppendBreak(new TimeSpan(0, 0, 2));
           
            promptBuilder.AppendText("尹成大哥是谁");
            promptBuilder.AppendTextWithHint(DateTime.Now.ToString("hh:mm"), SayAs.Time);
           
            // Pause for 2 seconds
            promptBuilder.AppendBreak(new TimeSpan(0, 0, 2));
           
            promptBuilder.AppendText("尹成大哥硕士毕业于中科院?");
           
            promptBuilder.StartVoice("Microsoft Sam");
            promptBuilder.AppendTextWithHint("queue", SayAs.SpellOut);
            promptBuilder.EndVoice();
           
            promptBuilder.AppendText("Do it faster!");
           
            promptBuilder.StartVoice("Microsoft Sam");
            promptBuilder.StartStyle(new PromptStyle(PromptRate.ExtraFast));
            promptBuilder.AppendTextWithHint("queue", SayAs.SpellOut);
            promptBuilder.EndStyle();
            promptBuilder.EndVoice();
 
            // Speak all the content in the PromptBuilder
            synthesizer.SpeakAsync(promptBuilder);
        }
    }
}

 

你可能感兴趣的:(C#)