SpeechSynthesizer.SpeakSsml

Published Sun, May 27 2007 23:20 | William

I quickly got annoyed when I was trying to fool around with the SpeechSynthesizer class.  I remember I got a SSML read working a while ago, but couldn't figure it out to save my life this time around.  Anyway, I couldn't get it to read correctly from a .ssml file but I'm pretty sure I know what the problem is.  Anyway, I got sick of playing with it for now and just wrote it out manually - lame yes, but it works:
private String BuildSSML()
{
  StringBuilder sb = new StringBuilder();
  sb.Append("<?xml version=''1.0''?> ");
  sb.Append("<speak version=''1.0'' ");
  sb.Append("xml:lang=''en-US''>");
  sb.Append("<voice gender=''female''> Hi, I'm Barbie Cummings even though I sound like a computer</voice>");
  sb.Append("");
  sb.Append(" <voice gender=''female'' variant=''2''>");
  sb.Append("This still isn't close");
  sb.Append(" </voice>");
  sb.Append("");
  sb.Append("<voice name=''EvilDevilCuckoo''>Barbie Cummings rulez</voice>");
  sb.Append("</speak>");
  return sb.ToString().Replace("''", '"'.ToString());
}

Then all you need to do is call the SpeakSsml method of the SpeechSynthesizer like this:


sz.SpeakSsml(BuildSSML());

Again though, this is just cursory stuff. You can really kick a55 with SSML if you want to.  For a little more on the spec if you're not familiar with it, look here

 

Search

This Blog

Tags

Community

Archives

News

My other sites

Cool Stuff

Book Stuff

Security

ORM

Data Access

Funny Stuff

Compact Framework Stuff

Web Casts

My KnowledgeBase Articles

My MVP Profile

Design Patterns

Performance

Debugging

Remoting

My Fellow Authors

My Books

LINQ

Misc

Speech

Syndication

Email Notifications