SSML allows you to build XML easily by using a fluent-ish SSML.
SSML
can be installed via the package manager console by executing the following commandlet:
PM> Install-Package SSML
or by using the dotnet CLI:
$ dotnet add package SSML
var xml = await new Ssml().Say("Hello")
.Say("World")
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>Hello World</speak>
var xml = await new Ssml().Say("Hello")
.Say("World")
.AsAlias("Bob")
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
Hello
<sub alias="Bob">World</sub>
</speak>
var xml = await new Ssml().Say("Hello")
.Say("World")
.Emphasised()
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
Hello
<emphasis>World</emphasis>
</speak>
var xml = await new Ssml().Say("Take a deep breath")
.Break()
.Say("then continue.")
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
Take a deep breath
<break />
then continue.
</speak>
var date = new DateTime(2017, 09, 15);
var xml = await new Ssml()
.Say("This code was written on")
.Say(date).As(DateFormat.YearMonth)
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
This code was written on
<say-as interpret-as="date" format="ym">201709</say-as>
</speak>
var time = new TimeSpan(20, 05, 33);
var xml = await new Ssml().Say("Bedtime is")
.Say(time).In(TimeFormat.TwentyFourHour)
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
Bedtime is
<say-as interpret-as="time" format="hms24">20:05:33</say-as>
</speak>
var xml = await new Ssml()
.Say("If you require a new job, please phone")
.Say("+44 (0)114 273 0281").AsTelephone()
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
If you require a new job, please phone
<say-as interpret-as="telephone">+44 (0)114 273 0281</say-as>
</speak>
var xml = await new Ssml()
.Say("It's as easy as")
.Say("abc").AsCharacters()
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
It's as easy as
<say-as interpret-as="characters" format="characters">abc</say-as>
</speak>
var xml = await new Ssml()
.Say("It's as easy as")
.Say("abc").AsCharacters().WithGlyphInformation()
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
It's as easy as
<say-as interpret-as="characters" format="characters" format="glyph">abc</say-as>
</speak>
var xml = await new Ssml()
.Say("We only have")
.Say(512).AsCardinalNumber()
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
We only have
<say-as interpret-as="cardinal">512</say-as>
</speak>
var xml = await new Ssml()
.Say("We only have")
.Say(512).AsOrdinalNumber()
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
We only have
<say-as interpret-as="ordinal">512</say-as>
</speak>
var xml = await new Ssml().Say("Hello")
.Say("World")
.AsVoice("en-US-Jessa24kRUS")
.ToStringAsync();
<?xml version="1.0" encoding="UTF-8"?>
<speak>
Hello <voice name=""en-US-Jessa24kRUS"">World</voice>
</speak>
https://docs.microsoft.com/en-us/azure/cognitive-services/speech-service/speech-synthesis-markup
var xml = await new Ssml(lang: "zh-CN")
.Say("这样做吗")
.Break().WithStrength(BreakStrength.ExtraStrong).For(TimeSpan.FromMilliseconds(100.1))
.Say("是的,它确实!")
.ToStringAsync();;
<?xml version="1.0" encoding="UTF-8"?>
<speak version="1.0" xml:lang="zh-CN">
这样做吗
<break strength="x-strong" time="100ms" />
是的,它确实!
</speak>
For full set of usages checkout the unit tests within the Kevsoft.Ssml.Tests
project.
- Fork
- Hack!
- Pull Request