Text to Speech.......Make MediaPortal Talk (2 Viewers)

Inker

Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Ok guys, following my post to the Alarm V2 plugin I thought I might as well also try to implent this.

    So, I got the basic code to speak a TextInput working, but it is not integrated with Mediaportal. I took a look into the CSV but to be honest, this is a bit too much for me small student-programmer. So if someone could help me getting this into MP that would be great.

    So heres what I thought, we create the Plugin once, and then every other plugin can use it to say specific things. So a method within MP that would say
    sayText(string input) .....

    would be the way to go.

    Now, inside that text we can have tags, such as <user>, <time>, <temperature> etc. which will then of course be replaced by their values.

    Example of an input text:

    "Good afternoon <name>, the time is <time>. Have fun with MediaPortal".

    Very easy, but I have no Idea how to get these values from MediaPortal. Name for instance isnt even set in the Config yet. Time of course I can read out, same for date, but with MP specific tags im having trouble (tbh I dont really dare touch the source code).

    So, what I have done for now is something like this:
    input = input.Replace("<name>",getUsername());

    meaning the Method to get these tags will have to be written later on.
    Works fine, but of course it fakes the return of the getter Methods.

    So........what does that mean..........I guess I need some help........is there even demand for this stuff? One perfect use would be that the system tells you things when the alarm goes off (see page three of the Alarm V3 Thread for my thoughts), or it could tell you when it starts recording, or it can read the news for you, or tell you about the weather while your watching TV/listening to music. Stuff like that. For the last instance it would be cool if the sound of Video/TV/Music would slightley fade out while MP is "talking".

    Ok, I'm guessing the post will get too long, let me know what you think

    Here is a small sample of what this could sound like (for an alarm with beeping and background music).
    http://www.geocities.com/nummer1_98/78nummer/Inker/public/share/morning_mixed.wma
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Heres what I have so far:

    private void sayText(string input)
    {
    /*
    * This method will say whatever Text is parsed to it, using the default SAPI 5 voice (please select in ur Windows Settings)
    * There are a few special tags which the plugin can use within the string. These tags will then be replaced with a value.
    * For the moment the tags are:
    * <name> is replaced with the username, example: "Steven"
    * <time> is replaced with the current time in the following format: 15:31
    * <date> is replaced with the current date in the following format: 12.01.2005
    * <currTemp> is replaced with the current temperature, format: 10 degrees
    * <currCond> is replaced with general weather conditions, example: Sunny
    * <forecastTemp> is replaced with the next forecast Temperatures, format: 10 degrees
    * <forecastCond> is replaced with the next forecast conditions, example: overcast
    * <newsource> is replaced with the selected source for news, example: CNN
    * <news:NumberOfHeadliensToRead> is replaced with with a string of news from the selected newssource covering the number of last headlines specified here
    * example usage: <news:5> will get the last 5 news headlines
    * <noRecordings> is replaced with the number of scheduled recordings today
    * <schRecordings> is replaced with the title of the scheduled recordings for today, example: Friends, Simpsons, Seinfeld
    *
    * this is open for future additions of course
    */

    Implementation of the SPEECH! part here
    }

    So this is the method I have, works fine. When it encounters any of the tags above the method will also call the appropriate method (see below) to replace the tag with an actualy value (exceptions are time/date which it gets directly from the system).
    The following method will still need to be implented, I need big help here though, maybe a developer could help me out?

    private string getUsername()
    private string getCurrTemp()
    private string getCurrCond()
    private string getForecastTemp()
    private string getForecastCond()
    private string getNewsSource()
    private string getNews(int NumberOfHeadlines)
    private string getNoSchRecordings()
    private string getSchRecordings()

    The speech part works fine, so you can have it say something nice already :)

    Now I just need to find out how to get it as a public method into MP....
     

    FlipGer

    Retired Team Member
  • Premium Supporter
  • April 27, 2004
    2,658
    115
    49
    Leipzig, Germany
    Home Country
    Germany Germany
    Hi,

    sound like an very interessting plugin! :) Nice idea.

    The best way to get in contact with the devs is IRC! See top right. ;)

    Looking forward to your plugin. :)

    HTH, Flip.
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    Thnx,

    Although the tags (except date and time) don't yet work, the talking works, so I have submitted it as a patch

    http://sourceforge.net/tracker/index.php?func=detail&aid=1098993&group_id=107397&atid=647927

    usage: TTS.sayText("Make MediaPortal say whatever you want, using the SAPI voice the user has selected in his windows properties.")

    Read the description for more details and let me know if this is useful at all.

    I hope other plugins will make use of this.

    Inker
     
    A

    Anonymous

    Guest
    I don't know how you make it speech, but it sounds great.

    "Good morning Nils. Get out of your fucking bed and go to university immediately! You're late as every morning!"

    Great :)
     

    LetterJ

    Portal Member
    May 15, 2005
    5
    0
    Minneapolis, MN
    I'll take a look

    I'll take a look at this in the next few days. I've done some work with the MS TTS engine in the past (though not in .NET or C#) and, when combined with one of the voices from Cepstral (see URL below), you can get remarkably nice speech.

    Incidentally, I found this thread checking to see if there's been any work done on voice recognition and this goes hand in hand. What I'd like to see is a set of voice commands for "Play DVD", "Load Music Library", etc. Run a condenser microphone to near the couch and make sure that all commands are prefaced by a "secret word" that seperates out anything movies themselves might feed into the microphone. Would result in conversational control of the HTPC.

    https://www.cepstral.com/cgi-bin/st...go3p0d9vgsg64ot9m5q05v29ji3l31vr85jo729197yu3
     

    CodeMonkey

    Portal Pro
    December 8, 2004
    360
    30
    North America
    Home Country
    United States of America United States of America
    I could see it being of use for the Caller ID plugin as well. If I can figure out where to put the tts patch in the MP code, I might get a chance to try it tonight :)

    I need the TTS engine from MS I suppose (or is it already in XP?). Is there anything else I'd need?

    Inker, your comment says ...

    This method will say whatever Text is parsed to it, using the default SAPI 5 voice (please select in ur Windows Settings)

    Where in Windows settings is this?
     

    LetterJ

    Portal Member
    May 15, 2005
    5
    0
    Minneapolis, MN
    Your best bet is to get the Speech SDK, but if you have a "Speech" entry in your control panel, the TTS engine should be in place.

    Here's a VBScript snippet that lists all of the current voices:

    Dim oTTS, sTab
    Set oTTS = WScript.CreateObject("SAPI.SpVoice")
    sTab = Chr(9)

    WScript.Echo "Lang" & sTab & "Name" & sTab & "Gender"
    For Each oVoice in oTTS.GetVoices("")
    WScript.Echo oVoice.GetAttribute("Language")& sTab & _
    oVoice.GetAttribute("Name")& sTab & _
    oVoice.GetAttribute("Gender")
    Next
     

    Inker

    Retired Team Member
  • Premium Supporter
  • December 6, 2004
    2,055
    318
    yes you will need the MS TTS to hear anything and the speechlib

    if you go to control panel-speech (something like that, im using the german version of windows) and if that is there then you should be able to hear tts

    its probably best to rewrite this entirely and put it somewhere into the core of MP....as you can see from my code its really not hard at all:

    code snippet:

    using SpeechLib;
    ...
    SpeechVoiceSpeakFlags SpFlags = peechVoiceSpeakFlags.SVSFlagsAsync;
    SpVoice Voice = new SpVoice();
    Voice.Speak(input,SpFlags); // input is what it will say

    thats all there is to it really.

    that speechlib is a dll which is also in the zip i uploaded.

    Hope this helped
     

    Users who are viewing this thread

    Top Bottom