1. Post #1
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    Description
    gSpeak is a module for gmod that lets you use Microsoft Speech from Lua. You can use it both on the server and the client, but it makes more sense on the client. If you use it on the server, gSpeak will not broadcast voice output to clients.
    Code:
    gspeak.Say(string message [, ushort volume, long rate])
    gspeak.IsSpeaking()
    gspeak.QueueSize()
    gspeak.Pause()
    gspeak.Resume()
    gspeak.Say makes your system default voice (XP: Sam, Vista: Anna) speak the provided message, optionally also at the provided volume and rate of speech. The volume is a value between 0 and 100, where 100 is the default. The rate is a value between -10 and 10, where 0 is typically the default. You can also use the SAPI's XML markup within the message to mutate the pitch, volume and rate of speech.

    gspeak.IsSpeaking returns a boolean value whether or not gspeak is currently saying anything.

    gspeak.QueueSize returns the amount of messages currently waiting to be spoken, including the one currently being spoken.

    gspeak.Pause pauses the voice temporarily before the next word. IsSpeaking returns false while the voice is paused; even if the voice is currently finishing up on a word before pausing.

    gspeak.Resume resumes a paused voice. You can use Pause and Resume even if the voice is already paused or is already speaking; they'll just return immediately, so there's no need to use IsSpeaking/QueueSize to check if pausing/resuming is viable.

    More on XML markup
    The XML markup can be used to modify the pronounciation of entire text or just portions of it. You can change attributes such as pitch, volume and rate using the embedded XML. You can also insert pockets of silence, or tell the voice how to pronounce something.

    More advanced features include making the current voice be chosen based on gender, age and language!

    I have not tested all of these features, but there's a detailed tutorial on the XML markup here.

    Example: Spoken chat
    Clientside script for speaking out chat (and notifications, leave messages):
    require("speak")
    
    local function speak(index, nick, msg, msgtype)
    		gspeak.Say(msg)
    end
    hook.Add("ChatText", "gspeak_saychat", speak)
    

    Example: Console command
    concommand.Add("tts", function(ply, cmd, args)
        if #args == 0 then print("Usage: speak <message>") return end
        gspeak.Say(table.concat(args, " "))
    end)
    
    Usage (in console):
    Code:
    tts SamuraiMushroom is a faggot!
    Todo
    Add a mechanism for choosing/getting the default voice and language.

    Temporary method of changing voice
    You have to select your system default voice in Control Panel->(Text To) Speech, the default voice is the one used by gspeak.

    Download v1.6.2
    Put gm_speak.dll in your lua/includes/modules/ folder to use.
    #luahelp download mirror
    filesmelt download mirror

    Credits
    Foss - came up with the idea
    Reply With Quote Edit / Delete Reply Norway Show Events Funny Funny x 8 (list)

  2. Post #2
    MajorVictory's Avatar
    May 2007
    93 Posts
    Some SAPI Documentation for ya. Not sure if it works though...

    http://www.w3.org/TR/speech-synthesis/#S3

  3. Post #3
    Gold Member
    Kill coDer's Avatar
    April 2006
    956 Posts
    If only you could stream this to clients...
    Reply With Quote Edit / Delete Reply Australia Show Events Agree Agree x 2 (list)

  4. Post #4
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    New version put up, now lets you supply the rate and volume.

    If only you could stream this to clients...
    I can only see this possible by sending the sound data to the client, generate a sound file in the data folder then play that file. This is extremely slow compared to regular techniques like VOIP.

  5. Post #5
    Gold Member
    Foss's Avatar
    May 2008
    61 Posts
    Idea stealer.
    Reply With Quote Edit / Delete Reply Finland Show Events Disagree Disagree x 2 (list)

  6. Post #6
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    Idea stealer.
    I'm pretty sure that many people had thought of the idea much earlier than you first even considered it.

    And having an idea doesn't give you credit to it. You actually need to create it.

    ...unless you take out a patent... but I doubt you could do that in this situation.


    Anyway: Awesomely Awesome module!
    Reply With Quote Edit / Delete Reply Australia Show Events Agree Agree x 1 (list)

  7. Post #7
    Gold Member
    Nevec's Avatar
    June 2008
    1,091 Posts
    I can only see this possible by sending the sound data to the client, generate a sound file in the data folder then play that file. This is extremely slow compared to regular techniques like VOIP.
    Doesn't source already have something like voip? You'd just need to bend the mic system to your way.

    Anyways.. Good work!

  8. Post #8
    Gold Member
    maurits150's Avatar
    February 2007
    1,808 Posts
    Very nice module. I only have a problem.
    When I use it, the game freezes until the voice has been finished saying its line.
    Am I the only person with this problem?

  9. Post #9
    CapsAdmin's Avatar
    August 2005
    3,934 Posts
    Very nice module. I only have a problem.
    When I use it, the game freezes until the voice has been finished saying its line.
    Am I the only person with this problem?
    Yeah it freezes gmod on my computer too.

  10. Post #10
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,015 Posts
    Threading would help with that problem, jA_cOp...

    I wonder if using the Lua Lanes module would work...

  11. Post #11
    ahref's Avatar
    July 2008
    191 Posts
    anyone not have the freezing problem?

  12. Post #12
    ahref's Avatar
    July 2008
    191 Posts
    WARNING: This file has been reported! It may be dangerous! Download at your own risk!
    If this is your file, don't waste your time editing the description to say the file is safe, if you do your file will be automatically deleted when it gets checked.
    :O who did that.

    EDIT: SORRY FOR DOUBLE POST!

  13. Post #13
    YYZ
    YYZ's Avatar
    March 2009
    15 Posts
    :O who did that.
    Pretty sure files with DLLs in them are auto-reported or some shit.

  14. Post #14
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    i figured since calling the speak function (which is done on module initialization) doesn't block, it would have no effect on the loading. So I assumed the freeze was because of the other loading stuff. I'll try taking that out and see what happens.

  15. Post #15
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    Alright when I take that out, the freeze happens the first time gspeak.Say is called instead.

    I could move the initialization into another thread though. I'll do that now.

    edit:

    Here we go:


    I could thread the whole initialization, but then the first script to require the module would get nil errors for global "gspeak", so I think it's best to leave the actual initialization blocking. The "gSpeak loaded" line has been moved into a seperate thread though, and I felt that it helped loading a little bit. Try it and see how it acts for you.

  16. Post #16
    CapsAdmin's Avatar
    August 2005
    3,934 Posts
    Still freezes for me on gspeak.Say, but not when it loads.

  17. Post #17
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    Still freezes for me on gspeak.Say, but not when it loads.
    Weird. Perhaps 'require' manages to return and call gspeak.Say in your script before my thread gets any time. Could you try doing require and gspeak.Say in seperate lua_run_cl commands? See if it freezes anywhere, and where.

  18. Post #18
    Gold Member
    maurits150's Avatar
    February 2007
    1,808 Posts
    Weird. Perhaps 'require' manages to return and call gspeak.Say in your script before my thread gets any time. Could you try doing require and gspeak.Say in seperate lua_run_cl commands? See if it freezes anywhere, and where.
    I just did this, and it still freezes.

  19. Post #19
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    I just did this, and it still freezes.
    With the newest version? And using "require" or "gspeak.Say"?

    Thanks for any help. I'm currently at a laptop where I get like 3 FPS in gmod under most conditions, so it's fairly difficult to get any decisive results from testing.

  20. Post #20
    CapsAdmin's Avatar
    August 2005
    3,934 Posts
    With the newest version? And using "require" or "gspeak.Say"?

    Thanks any help. I'm currently at a laptop where I get like 3 FPS in gmod under most conditions, so it's fairly difficult to get any decisive results from testing.
    I tried this, too.

    And yeah with the latest version.

  21. Post #21
    mbainrot's Avatar
    August 2008
    178 Posts
    Links dead

    Fucking 12yr paranoid c****....

  22. Post #22
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts


    New link up. It's a legit module and the source is included, why would anyone take it down? :S

  23. Post #23
    Gold Member
    HubmaN's Avatar
    July 2007
    6,267 Posts
    Anyone try this on Wine yet?
    Reply With Quote Edit / Delete Reply Thailand Show Events Funny Funny x 1 (list)

  24. Post #24
    Gold Member
    Kogitsune's Avatar
    September 2005
    2,788 Posts


    New link up. It's a legit module and the source is included, why would anyone take it down? :S
    Aren't DLLs auto-reported?

  25. Post #25
    mbainrot's Avatar
    August 2008
    178 Posts
    who knows, (I host my dll shit on my website)

  26. Post #26
    mbainrot's Avatar
    August 2008
    178 Posts
    Its brilliant, only prob is that its a halting call, the game locks up for 1/2 of a second while the call runs, have you tried calling it in its own "thread"?

  27. Post #27
    Internet Detective (HBIED certified)
    leach139's Avatar
    August 2007
    7,213 Posts
    Anyone try this on Wine yet?
    As far as I'm aware, the WinE codebase doesn't have any binaries for TextToSpeech. Either try Crossover (I'll do this soon) or submit a Feature Request.

  28. Post #28
    Get your own DarkRP Server!
    FPtje's Avatar
    January 2006
    5,591 Posts
    I'm pretty sure that many people had thought of the idea much earlier than you first even considered it.

    And having an idea doesn't give you credit to it. You actually need to create it.

    ...unless you take out a patent... but I doubt you could do that in this situation.


    Anyway: Awesomely Awesome module!
    Haha I remember requesting this once too but that was years ago.

    Can't you send the module to the client and just send the text to a clientside lua file to let the client pay it? (I have no experience with modules so I don't know...)

  29. Post #29
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    Anyone try this on Wine yet?
    Wine does not support any replacement for Windows' SAPI.

    Aren't DLLs auto-reported?
    Yeah, but it takes a moderator to look at it and take it down instead of mark it as checked and legit.

    Its brilliant, only prob is that its a halting call, the game locks up for 1/2 of a second while the call runs, have you tried calling it in its own "thread"?
    It only freezes the first time it speaks.

    I am using a thread for the first time, but there's a way for Lua to grab that first call before the thread I am starting. I'll make a fix for it eventually. (by yielding the thread that calls the module's Init function, after launching the thread.)

    Can't you send the module to the client and just send the text to a clientside lua file to let the client pay it? (I have no experience with modules so I don't know...)
    You cannot send modules to the client. Well, you can, but not to the directory where you can load them in Lua. This is a good thing, else any server could do anything they wanted to on their clients.

  30. Post #30
    mbainrot's Avatar
    August 2008
    178 Posts
    Wine does not support any replacement for Windows' SAPI.



    Yeah, but it takes a moderator to look at it and take it down instead of mark it as checked and legit.



    It only freezes the first time it speaks.

    I am using a thread for the first time, but there's a way for Lua to grab that first call before the thread I am starting. I'll make a fix for it eventually. (by yielding the thread that calls the module's Init function, after launching the thread.)



    You cannot send modules to the client. Well, you can, but not to the directory where you can load them in Lua. This is a good thing, else any server could do anything they wanted to on their clients.
    for me it locks up everytime, Damn I miss vista :( (right now i am on Win XP Pro SP3)

  31. Post #31
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    New version that doesn't freeze.



    It doesn't say anything on startup either.

    edit:

    There is a better way to thread this than what I am doing, I'll probably do that later if I work more on this.

  32. Post #32
    ahref's Avatar
    July 2008
    191 Posts
    Not entirely sure if its just me but im not getting any output with this. is anyone else having the problem?

  33. Post #33
    Mr Affinity's Avatar
    September 2007
    526 Posts
    1.3 is working perfectly for me.

  34. Post #34
    Creator of Exsto
    Prefan's Avatar
    January 2009
    1,049 Posts
    Too bad this can't be streamed from the server to the clients, so much use could come out of this.

  35. Post #35
    mbainrot's Avatar
    August 2008
    178 Posts
    load 'n' her up now, i'll post with results :D

  36. Post #36
    Grocel's Avatar
    October 2008
    1,221 Posts
    There is no download link. :(

  37. Post #37
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    Put up a working download that isn't from garrysmod.org.

    What dumb garrysmod.org moderator would seriously keep removing this?

  38. Post #38
    Nerdboy's Avatar
    July 2007
    891 Posts
    Are you putting them in zip files?

  39. Post #39
    Gold Member
    jA_cOp's Avatar
    May 2006
    2,685 Posts
    Yes, they've all been in zip files.

    VERSION 1.4
    http://upl.luahelp.com/uploads/z9PsX...peak%201.4.zip

    No new features, just fixed some issues before people would start noticing them. It now only uses a max of one thread for speaking, instead of one thread per gspeak.Say call (which remains until the message has been spoken).

    This means that you could now do:
    for counter = 1, 9001 do
        gspeak.Say(tostring(counter))
    end
    
    Without creating 9001 threads. It now queues messages instead and keeps one thread alive when the queue is not empty.

  40. Post #40
    Grocel's Avatar
    October 2008
    1,221 Posts
    When you use this module and leave the game then comes to a crash. :(

    Can you fix this please? :)