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.
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.Say(string message [, ushort volume, long rate])
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):
local function speak(index, nick, msg, msgtype)
hook.Add("ChatText", "gspeak_saychat", speak)
Example: Console command
Usage (in console):
concommand.Add("tts", function(ply, cmd, args)
if #args == 0 then print("Usage: speak <message>") return end
gspeak.Say(table.concat(args, " "))
tts SamuraiMushroom is a faggot!
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.
Put gm_speak.dll in your lua/includes/modules/ folder to use.
#luahelp download mirror
filesmelt download mirror
Foss - came up with the idea