Raised This Month: $32 Target: $400
 8% 

[STOCK] Voice Ware (Text To Speech)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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, 318 views)
File Type: sp Get Plugin or Get Source (voiceware_test.sp - 336 views - 602 Bytes)
File Type: smx voiceware_test.smx (4.5 KB, 325 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
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:20.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode