Shoutbox

getting a message and a sound together - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: getting a message and a sound together (/showthread.php?tid=95831)

getting a message and a sound together by OmarNajdi on 11-11-2010 at 03:12 PM

hi
how can i use a sound when i write a message?

for example when i write (Please) it plays a sound
i really need this code ( It's my school project )
thx


RE: getting a message and a sound together by matty on 11-11-2010 at 04:37 PM

Do you mean how do you play a sound on your local computer when you type a message or are you wanting to play a sound on your contact's computer when you type a specific message?

The first one is possible the second one both would need the script.

You will need to give us more details on how this is supposed to work so we can point you in the correct direction.


RE: getting a message and a sound together by OmarNajdi on 11-11-2010 at 07:51 PM

first, thanks for trying to help , i wish you continue with me

OK I didn't understand if the second one isn't possible
I wish to know each one how I can do it if it's possible

and here is the code

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message){
    switch (Message){
        case "/sstart":
            sEnabled = true
            return '';
        case "/sstop":
            sEnabled = false;
            return '';
        default:
            if (sEnabled = true){
                Message = Message.replace(/that/gi,"ðæt");
                return "" +Message;
        }


OK i need the letter in red to be spoken after i send it
where should I write the code and how

thanks a lot,
Omar
RE: getting a message and a sound together by whiz on 11-11-2010 at 08:38 PM

You still need to tell us a bit more about what exactly you want to achieve here.

  • What exactly do you want to be played?  Do you want the message to be read out, or a specific sound?
  • Do you want to hear the sound, or do you want the contact to hear it?
JScript code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
    switch (Message)
    {
        case "/sstart":
            sEnabled = true;
            return "";
        case "/sstop":
            sEnabled = false;
            return "";
        default:
            if (sEnabled)
            {
                Message = Message.replace(/that/gi, "ðæt");                return Message;
            }
            break;
    }
}

  • What is the replace line for?  Do you want to play the sound if the replacement occurs in the message?
Also, you should use [code=js] for syntax highlighting when posting your code here.  ;)
RE: getting a message and a sound together by OmarNajdi on 11-12-2010 at 01:23 AM

sry about the code cuz I'm new

OK, i need the word (that) to be played for the one who I'm talking with after i write it
I wish it could be the message I've written, but there's no problem to be a specific sound that I've recorded
the replace line is for replacing the word to another word, the same word i need to hear

thank you.


RE: getting a message and a sound together by ryxdp on 11-12-2010 at 11:39 AM

If you're talking about text-to-speech, I've written a script to do just that, using Windows's default TTS engine. It narrates your contact's messages with the option of saying display names as well as your own messages. Hopefully this'll help, but as it's for your school project it might not be the best of solutions. Still, you can take a look through the code if you want and adapt it to how you like, just ask and I can send it to you :P


RE: getting a message and a sound together by OmarNajdi on 11-15-2010 at 11:59 AM

that's exactly what I want
it's not necessary to be my school project , it's just an idea
please send it to me , I'll me so grateful
sorry for the delay
and I'm waiting


RE: getting a message and a sound together by CookieRevised on 11-15-2010 at 06:25 PM

Some basic (and a bit more advanced) examples of using the Windows Speech API in JScript:

JScript code:
var oVoice = new ActiveXObject("SAPI.SpVoice");
 
with (oVoice) {
    Voice = GetVoices()[0];
    Volume = 100;
 
    // basic example
    Rate = 1;
    Speak("Hello. This is a basic example of the speech Windows API");
 
    // XML example, changing pitch
    Rate = -2;
    Speak('<pitch middle="-25">Hello, I am a robot</pitch>' ,8);
 
    // XML example, using some other tags
    Rate = 0;
    Speak('<pitch absmiddle="30"><rate absspeed="-2">Now I\'m going to use a whining voice to spell the word: school<silence msec="500"/><rate speed="-3"><spell>school</spell></rate></rate></pitch>', 8);
 
    // XML example, difference in pronunciations
    Rate = 0;
    Speak('Did you <partofsp part="verb">record</partofsp> that <partofsp part="noun">record</partofsp>?',8);
}

You can do a lot more though.
The SAPI help file (sapi.chm) can be downloaded from:
http://www.microsoft.com/downloads/en/details.asp...-B0EE-6583171B4530
RE: getting a message and a sound together by OmarNajdi on 11-18-2010 at 02:05 AM

sorry for my late answer

now how can I get this sound when I type it ?
where should I put the code ?


RE: getting a message and a sound together by whiz on 11-18-2010 at 10:22 AM

You should use the OnEvent_ChatWndReceiveMessage() function.  Define the ActiveX object globally (outside any functions).  Then you can pass the Message parameter to oVoice.Speak() within the message event.


RE: getting a message and a sound together by OmarNajdi on 11-18-2010 at 11:50 AM

OK now how the final code will be?
all of the above together?


RE: getting a message and a sound together by matty on 11-18-2010 at 11:55 AM

quote:
Originally posted by OmarNajdi
OK now how the final code will be?
all of the above together?
Why don't you try instead of asking everyone to do it for you?

Read the documentation, look at the forms for other examples... I am sure you could figure it out.
RE: getting a message and a sound together by OmarNajdi on 11-18-2010 at 09:57 PM

I've tried to do it on my one
but the script wasn't right
That's why I ask you
I'm sorry if I ask so much


RE: getting a message and a sound together by matty on 11-18-2010 at 10:07 PM

Post what you have done and we will point you in the right direction on fixing it.