SpeechSynthesizer.SpeakSsml

Published 27 May 7 11:20 PM | 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

  • William G Ryan William Ryan Bill Ryan W.G. Ryan Charles Mark Carroll Charles M Carroll
    My Blog Juice Microsoft MVP
    Bill Ryan W.G. Ryan William Ryan
    Cuckooz' MySpace Page View Bill Ryan's profile on LinkedIn
    My Profile on Twitter
    Please note that this is my personal blog and the opinions expressed are my own. Also, comment moderation is about one of the least important things in my life so please keep that in mind. I can't vouch for the authenticity of any of the posters so please don't hold me accountable. And whatever you do, don't pretend to be Noted Option Strict Off expert and AspFriend Charles Mark Carroll when you post. Doing so will lead him to become apoplectic and write absurd accusatory posts about me that are as coherent and thought out as they are factually correct. He does a stellar job proving his reputation is well deserved and he doesn't need any help from you making himself look foolish. If I have to listen to him banging his spoon off of his high chair one more time, I'm going to burst into flames so please don't make that happen!

    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