0

Sometimes I have a number like #12543 and I want the synthesizer to say "Number one-two-five-four-three".

Other times I would like the synthesizer to say "Number twelve-thousand-five-hundred-fourty-three".

Does anybody here know what mechanism in System.Speech regulates the pronunciation of these numbers?

Fred Chateau
  • 869
  • 1
  • 6
  • 16

1 Answers1

1

Look at the SayAs Enumeration and the AppendTextWithHint Method, this example is based on the Microsoft documentation.

using System;
using System.Speech.Synthesis;

namespace ConsoleApplication66
{
    class Program
    {
        static void Main(string[] args)
        {
            SpeechSynthesizer synth = new SpeechSynthesizer();
            synth.SetOutputToDefaultAudioDevice();
            PromptBuilder talk = new PromptBuilder();
            talk.AppendText("#12543");
            talk.AppendTextWithHint("#12543", SayAs.SpellOut);
            talk.AppendTextWithHint("#12543", SayAs.NumberOrdinal);
            talk.AppendTextWithHint("#12543", SayAs.NumberCardinal);
            synth.Speak(talk);

        }
    }
}
Mark Hall
  • 53,938
  • 9
  • 94
  • 111