Bonsoir, All
Je voudrais incorporé dans mon serveurs la traductions des phrases des gens dans le chat.
J'ai réussie en revanche des problèmes se pose, déjà les voix ne sont pas du tous forte ( Donc il faudrait les faire parler plus fort ) et le deuxièmes soucie c'est que la traduction et instantané je voudrais qu'elle s'active après avoir marqué sa par exemple : " !! Bonjour ! " mon dernier soucie et que les voix sont anglais alors que dans mon fichiers j'ai remplacé par le google translate fr.
Merci d'avance pour les divers réponses pour informations voici le codage :
Je voudrais incorporé dans mon serveurs la traductions des phrases des gens dans le chat.
J'ai réussie en revanche des problèmes se pose, déjà les voix ne sont pas du tous forte ( Donc il faudrait les faire parler plus fort ) et le deuxièmes soucie c'est que la traduction et instantané je voudrais qu'elle s'active après avoir marqué sa par exemple : " !! Bonjour ! " mon dernier soucie et que les voix sont anglais alors que dans mon fichiers j'ai remplacé par le google translate fr.
Merci d'avance pour les divers réponses pour informations voici le codage :
local accents = {
"
"
"
}
local wait = false
local channels = {}
local function playvoice(ply,text,accent,speed)
if wait then
accent = "
end
sound.PlayURL(accent..text,"3d noplay",function(channel,errorid,errorname)
if channel == nil || errorid != nil || errorname != nil then --peniscorp backup; google is upset
if wait == false then
wait = true
timer.Simple(125,function() wait = false end)
playvoice(ply,text,accent,speed)
end
return
end
channel:SetPos(ply:GetPos(),Vector(0,0,0))
channel:Set3DFadeDistance(9999999999,9999999999)
channel:SetPlaybackRate(math.Clamp(.6+speed,.5,2))
channel
lay()
table.insert(channels,{channel,ply})
end)
end
hook.Add("Think","TTSThink",function()
for k, v in pairs(channels) do
if !v[1]:IsValid() then table.remove(channels,k) return end
if v[2] == nil ||
v[1]:GetState() != GMOD_CHANNEL_PLAYING ||
v[1]:GetTime() >= v[1]:GetLength() then
v[1]:Stop()
table.remove(channels,k)
return
end
v[1]:SetPos(v[2]:GetPos(),Vector(0,0,0))
end
end)
hook.Add("OnPlayerChat","TTSPlayerChat",function(ply,text,team,dead)
--firstly, checking for popular gamemode limitations
local dotts = true
if engine.ActiveGamemode() == "jailbreak" then
if dead then dotts = false end
if ply.IsSpec != nil && ply:IsSpec() then dotts = false end
end
if engine.ActiveGamemode() == "jailbreak" then
if text[1] == "/" then dotts = false end
if ply:GetPos()
istance(LocalPlayer():GetPos()) > 99999999999 then dotts = false end --250 = default chat range
end
if dotts then
local speed,accent,nick = 1, accents[1], ply:Nick()
local nlen = #nick
local vowels, vow, notvow, vrat = {"a","e","i","o","u","y"}, 0, 0, 1
for i = 1, nlen do
if table.HasValue(vowels,nick) then vow = vow+1 else notvow = notvow+1 end
end
if vow == 0 then notvow = nlen end
vrat = vow/notvow
accent = accents[math.Clamp(vow,1,#accents)]
speed = vrat
playvoice(ply,text,accent,speed)
end
end)
"
Vous devez être inscrit pour voir les liens ! Inscrivez-vous ou connectez-vous ici.
","
Vous devez être inscrit pour voir les liens ! Inscrivez-vous ou connectez-vous ici.
","
Vous devez être inscrit pour voir les liens ! Inscrivez-vous ou connectez-vous ici.
"}
local wait = false
local channels = {}
local function playvoice(ply,text,accent,speed)
if wait then
accent = "
Vous devez être inscrit pour voir les liens ! Inscrivez-vous ou connectez-vous ici.
"end
sound.PlayURL(accent..text,"3d noplay",function(channel,errorid,errorname)
if channel == nil || errorid != nil || errorname != nil then --peniscorp backup; google is upset
if wait == false then
wait = true
timer.Simple(125,function() wait = false end)
playvoice(ply,text,accent,speed)
end
return
end
channel:SetPos(ply:GetPos(),Vector(0,0,0))
channel:Set3DFadeDistance(9999999999,9999999999)
channel:SetPlaybackRate(math.Clamp(.6+speed,.5,2))
channel

table.insert(channels,{channel,ply})
end)
end
hook.Add("Think","TTSThink",function()
for k, v in pairs(channels) do
if !v[1]:IsValid() then table.remove(channels,k) return end
if v[2] == nil ||
v[1]:GetState() != GMOD_CHANNEL_PLAYING ||
v[1]:GetTime() >= v[1]:GetLength() then
v[1]:Stop()
table.remove(channels,k)
return
end
v[1]:SetPos(v[2]:GetPos(),Vector(0,0,0))
end
end)
hook.Add("OnPlayerChat","TTSPlayerChat",function(ply,text,team,dead)
--firstly, checking for popular gamemode limitations
local dotts = true
if engine.ActiveGamemode() == "jailbreak" then
if dead then dotts = false end
if ply.IsSpec != nil && ply:IsSpec() then dotts = false end
end
if engine.ActiveGamemode() == "jailbreak" then
if text[1] == "/" then dotts = false end
if ply:GetPos()
end
if dotts then
local speed,accent,nick = 1, accents[1], ply:Nick()
local nlen = #nick
local vowels, vow, notvow, vrat = {"a","e","i","o","u","y"}, 0, 0, 1
for i = 1, nlen do
if table.HasValue(vowels,nick) then vow = vow+1 else notvow = notvow+1 end
end
if vow == 0 then notvow = nlen end
vrat = vow/notvow
accent = accents[math.Clamp(vow,1,#accents)]
speed = vrat
playvoice(ply,text,accent,speed)
end
end)