View Single Post
Author Message
Franc1sco
Veteran Member
Join Date: Oct 2010
Location: Spain (Madrid)
Old 07-31-2014 , 17:19   [STOCK] Voice Ware (Text To Speech)
Reply With Quote #1

I made this stock for use a "Text To Speech" feature in SourceMod easily.


Stocks:
PHP Code:
/**
 * Sent text to speech to a client
 *
 * @param client            Client target.
 * @param language           Language of voice.
 * @param text            Text to reproduce.
 *                
 */
stock void VoiceWare(int clientchar[] languagechar[] text
{
    
ReplaceString(text255"&"""); // prevent error
    
char buffer[255];
    
Format(buffersizeof(buffer), "https://translate.google.com/translate_tts?ie=UTF-8&q=%s&tl=%s&client=tw-ob&ttsspeed=1.0"textlanguage); // use google traductor TTS
    
Handle Radio CreateKeyValues("data");
    
KvSetString(Radio"title""Voice Ware");
    
KvSetString(Radio"type""2");
    
KvSetString(Radio"msg"buffer);
    
ShowVGUIPanel(client"info"Radiofalse);
    
CloseHandle(Radio);
}

/**
 * Sent text to speech to all clients
 *
 * @param language           Language of voice.
 * @param text            Text to reproduce.
 *                
 */
stock void VoiceWareToAll(char[] languagechar[] text
{
    for (
int i 1<= MaxClientsi++)
        if(
IsClientInGame(i))
            
VoiceWare(ilanguagetext); 


Example plugin:
PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <voiceware>
 
#define LANGUAGE "en" // language voice used

public Plugin myinfo =
{
    
name "SM Chat text to voice",
    
description "Text to voice",
    
author "Franc1sco franug",
    
version "1.0",
    
url "http://steamcommunity.com/id/franug"
};

public 
void OnPluginStart()
{
    
RegConsoleCmd("say"Say);
}
 
public 
Action Say(int clientint args)
{
    if (
client!=0)
    {
        
char buffer[255];
        
GetCmdArgString(buffer,sizeof(buffer));
        
StripQuotes(buffer);
        
VoiceWareToAll(LANGUAGEbuffer);
    }  
    return 
Plugin_Continue;

Attached Files
File Type: inc voiceware.inc (1.0 KB, 321 views)
File Type: sp Get Plugin or Get Source (voiceware_test.sp - 341 views - 602 Bytes)
File Type: smx voiceware_test.smx (4.5 KB, 335 views)
__________________
Veteran Coder -> Activity channel
Coding on CS2 and taking paid and free jobs.

Contact: Steam, Telegram or discord ( franug ).

You like my work? +Rep in my steam profile comments or donate.


Last edited by Franc1sco; 08-29-2018 at 07:43.
Franc1sco is offline
Send a message via MSN to Franc1sco