2

i am trying to highlight words read by the text to speech but its not working. until now i made:

    string startSpan = "<span style=" + "background-color:Yellow" + ">";
    string endSpan = "</span>";

 //button onclick
protected void speak_Hope(object sender, EventArgs e)
    {
            speaker.Rate = -4;
            speaker.SpeakAsync(announce.InnerText);
            speaker.SpeakProgress += new EventHandler<SpeakProgressEventArgs>    (speaker_SpeakProgress);
            System.Diagnostics.Debug.WriteLine("processing");

    }


void speaker_SpeakProgress(object sender, SpeakProgressEventArgs  e)
    {
        counter2 = e.CharacterPosition - 10;
        counter3 = e.Text.Length;
        counter4 = counter2 + counter3;
        System.Diagnostics.Debug.WriteLine(e.CharacterPosition - 10 + " next one" + e.Text);
        announce.InnerHtml = announce.InnerText.Substring(0, counter2) + startSpan + announce.InnerText.Substring(counter2, counter3) + endSpan + announce.InnerText.Substring( announce.InnerText.Length - 1);


    }

am i doing it right or is there any other way, can it be done in a javascript manner? thanks alot

Adrian De Barro
  • 495
  • 2
  • 6
  • 21
  • What is not working? Are you getting an error message or no output, or the event is not being fired, or? – Joshua Drake Apr 19 '12 at 20:29
  • there is no highlighting of the text in the announcment "
    " but the offsets are written to the debugger console and variables change.
    – Adrian De Barro Apr 19 '12 at 20:36
  • 2
    You show server side code, but then mention `
    ` unless the page is posting back for every word read, or you are using a [WebBrowser Control](http://msdn.microsoft.com/en-us/library/aa752040%28v=vs.85%29.aspx), you will not be able to update the HTML.
    – Joshua Drake Apr 19 '12 at 20:40
  • 1
    Your `""` seems to be trying to escape the double quotes. What it's actually ending up with is ``. I think you want `""`, which produces ``. I doubt this is related to your problem, just pointing out another issue. – Tim S. Apr 19 '12 at 20:47
  • @TimS. thanks i will sort it out though too :) – Adrian De Barro Apr 19 '12 at 20:55
  • @JoshuaDrake i will try and use webbrowser controls. do you have any idea if it can be done in javascript? thanks a million for you help :) – Adrian De Barro Apr 19 '12 at 20:55
  • If you were to try it _in javascript_ you would need [Ajax](http://www.asp.net/ajax), so you can push the updates to the client. – Joshua Drake Apr 19 '12 at 20:57
  • @JoshuaDrake do you know a good tutorial on how to use webbrowser controls? – Adrian De Barro Apr 19 '12 at 21:50
  • @AdrianDeBarro What type of project are you currently working in? If you are building a web application / web site you are not going to be able to utilize SpeakRecognition, and based on your html code I'm concerned that this is what you're attempting. – vpiTriumph Apr 20 '12 at 01:27
  • @vpiTriumph yes im part of a team of students, building a portal application, part of my job was to try and implement text to speech for the web site. can you tell me why pls? – Adrian De Barro Apr 20 '12 at 06:35

1 Answers1

0

In the case you are looking for text to speech this is a possible duplicate of this Stackoverflow Question. That question provides the suggestion of using WebAnywhere, this provides speech to text without any additional downloads or special software. Pretty cool!

However, it seems like you are actually looking to achieve speech recognition. Based on your code you are heading down the wrong rabbit hole. You are not going to be able to use the Microsoft Speech libraries to accomplish this goal (short on embedding them in an XBAP) and this is a result of them running on the server and not on the client side.

There are some Flash and Java based solutions that will indeed allow for client side voice recognition. I suggest you explore them because I believe they achieve what you're looking for.

1) Speech API - Open source and their website includes a range of demos that I found to work quite well. 2) wami - Also open source

Community
  • 1
  • 1
vpiTriumph
  • 3,116
  • 2
  • 27
  • 39
  • im not doing speech recognition but text to speech but i think i would have the same problem thought. but this morining i googled for alternatives and i found the speech API which is all written in javascript which you told me that it works quite well. therefore i think i will implement it in that way thanks alot for your time and patience :) – Adrian De Barro Apr 20 '12 at 16:38
  • @AdrianDeBarro great, I'm glad you figured something out! Do you mind either posting and accepting your own answer or accepting this one? That way if someone has a similar question they can quickly decipher how your problem was solved. – vpiTriumph Apr 21 '12 at 04:41
  • do you have any idea how i can get the offset of current being read word from the speech api? – Adrian De Barro Apr 22 '12 at 18:39