XML from previous speech samples

The last few samples I've posted have used APIs to construct the input to the speech engines. Under the covers, you can conceptualize these as creating XML files (or at least, they correspond to XML files and can be serialized as such).

The PromptBuilder class creates XML in W3C's SSML format. The example I posted yesterday results in this XML:

<

speak version="1.0" xmlns="https://www.w3.org/2001/10/synthesis" xml:lang="en-US">

<

voice name="Microsoft Sam">

I am Sam. Sam I am. Today's date is

<

say-as interpret-as="datemonthday">7/1</say-as>

<

voice name="Microsoft Mike">

I'm Mike. Anything Sam can do I can do better.

<

voice name="Microsoft Mary">

I'm Mary. Anything Mike and Sam can do I can do too.

<

break time="1000ms" />

</

voice>

But can you spell potato?

<

say-as interpret-as="spellout">potato</say-as>

What do you think, Sam?

</

voice>

That's the stuff dreams are made of.

</voice>

</

speak>

You can get this by using the PromptBuilder's ToXML() method. Here's some code showing how to stream this to a file:

   Dim s As New System.IO.FileStream("c:\ssmlsample.xml", IO.FileMode.OpenOrCreate)

   Dim w As New System.IO.StreamWriter(s)

   w.Write(pb.ToXml())

   w.Close()

   s.Close()

The grammar from the math example is:

<

grammar xml:lang="en-US" root="product" version="1.0" xmlns="https://www.w3.org/2001/06/grammar">

<

rule id="product">

<

item repeat="0-1">

<

one-of>

<

item>1</item>

<

item>2</item>

<

item>3</item>

<

item>4</item>

<

item>5</item>

<

item>6</item>

<

item>7</item>

<

item>8</item>

<

item>9</item>

<

item>10</item>

</

one-of>

</

item>

<

item repeat="0-1">

<

one-of>

<

item>x</item>

<

item>y</item>

</

one-of>

</

item>

<

item repeat="0-1">

<

one-of>

<

item>x</item>

<

item>y</item>

</

one-of>

</

item>

</

rule>

</

grammar>

You can get this by using the SrgsDocument class' WriteSrgs() method. For example:

Dim s As New System.IO.FileStream("c:\srgssample.xml", IO.FileMode.OpenOrCreate)

Dim x As New System.Xml.XmlTextWriter(s, System.Text.Encoding.UTF8)

srgs.WriteSrgs(x)

x.Close()

s.Close()

The benefit of using the W3C XML formats is of course that although we provide APIs for generating the input to the speech engines, you can alternatively create the input as XML files using whatever tools you find appropriate.