фикс укр акцента
This commit is contained in:
parent
ab94ab3bcd
commit
2a7485aafd
4 changed files with 43 additions and 12 deletions
|
|
@ -42,7 +42,7 @@ namespace Content.Server.GameTicking.Commands
|
|||
return;
|
||||
}
|
||||
|
||||
ticker.SetGamePreset(ticker.Preset, false, rounds);
|
||||
ticker.SetGamePreset(preset, false, rounds);
|
||||
shell.WriteLine(Loc.GetString("set-game-preset-preset-set-finite", ("preset", preset.ID), ("rounds", rounds.ToString())));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Content.Server._Sunrise.Speech.Components;
|
||||
using Content.Server.Speech;
|
||||
using Content.Server.Speech.Components;
|
||||
using Content.Server._Sunrise.TTS;
|
||||
using Content.Server.Speech.EntitySystems;
|
||||
using Content.Shared.Speech;
|
||||
|
||||
|
|
@ -13,6 +13,7 @@ public sealed class UkrainianAccentSystem : EntitySystem
|
|||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<UkrainianAccentComponent, AccentGetEvent>(OnAccent);
|
||||
SubscribeLocalEvent<UkrainianAccentComponent, TTSSanitizeEvent>(OnSanitize);
|
||||
}
|
||||
|
||||
private string Accentuate(string message)
|
||||
|
|
@ -26,9 +27,13 @@ public sealed class UkrainianAccentSystem : EntitySystem
|
|||
accentedMessage[i] = c switch
|
||||
{
|
||||
'и' => 'і',
|
||||
'И' => 'І',
|
||||
'ы' => 'и',
|
||||
'Ы' => 'И',
|
||||
'ё' => 'ї',
|
||||
'Ё' => 'Ї',
|
||||
'е' => 'є',
|
||||
'Е' => 'Є',
|
||||
_ => accentedMessage[i]
|
||||
};
|
||||
}
|
||||
|
|
@ -40,4 +45,16 @@ public sealed class UkrainianAccentSystem : EntitySystem
|
|||
{
|
||||
args.Message = Accentuate(args.Message);
|
||||
}
|
||||
|
||||
private void OnSanitize(EntityUid uid, UkrainianAccentComponent component, TTSSanitizeEvent args)
|
||||
{
|
||||
var text = args.Text.Trim();
|
||||
text = Regex.Replace(text, "[іІ]", "и");
|
||||
text = Regex.Replace(text, "[їЇ]", "ё");
|
||||
text = Regex.Replace(text, "[єЄ]", "е");
|
||||
text = Regex.Replace(text, "[ґҐ]", "г");
|
||||
text = Regex.Replace(text, "[еЕ]", "э");
|
||||
text = text.Trim();
|
||||
args.Text = text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,6 @@ public sealed partial class TTSSystem
|
|||
private string Sanitize(string text)
|
||||
{
|
||||
text = text.Trim();
|
||||
text = Regex.Replace(text, "[іІ]", "и");
|
||||
text = Regex.Replace(text, "[їЇ]", "ё");
|
||||
text = Regex.Replace(text, "[єЄ]", "е");
|
||||
text = Regex.Replace(text, "[ґҐ]", "г");
|
||||
text = Regex.Replace(text, "[еЕ]", "э");
|
||||
text = Regex.Replace(text, @"[^a-zA-Zа-яА-ЯёЁ0-9,\-+?!. ]", "");
|
||||
text = Regex.Replace(text, @"[a-zA-Z]", ReplaceLat2Cyr, RegexOptions.Multiline | RegexOptions.IgnoreCase);
|
||||
|
|
@ -142,8 +138,8 @@ public sealed partial class TTSSystem
|
|||
{"с4", "Си 4"}, // cyrillic
|
||||
{"c4", "Си 4"}, // latinic
|
||||
{"бсс", "Бэ Эс Эс"},
|
||||
{"квилу", "Ху Ил Лу"},
|
||||
{"qillu", "Ху Ил Лу"},
|
||||
{"квилу", "хуиллу"},
|
||||
{"qillu", "хуиллу"},
|
||||
};
|
||||
|
||||
private static readonly IReadOnlyDictionary<string, string> ReverseTranslit =
|
||||
|
|
|
|||
|
|
@ -106,7 +106,11 @@ public sealed partial class TTSSystem : EntitySystem
|
|||
return;
|
||||
}
|
||||
|
||||
HandleRadio(args.Receivers, args.Message, protoVoice);
|
||||
var accentEvent = new TTSSanitizeEvent(args.Message);
|
||||
RaiseLocalEvent(args.Source, accentEvent);
|
||||
var message = accentEvent.Text;
|
||||
|
||||
HandleRadio(args.Receivers, message, protoVoice);
|
||||
}
|
||||
|
||||
private bool GetVoicePrototype(string voiceId, [NotNullWhen(true)] out TTSVoicePrototype? voicePrototype)
|
||||
|
|
@ -155,13 +159,17 @@ public sealed partial class TTSSystem : EntitySystem
|
|||
return;
|
||||
}
|
||||
|
||||
var accentEvent = new TTSSanitizeEvent(args.Message);
|
||||
RaiseLocalEvent(uid, accentEvent);
|
||||
var message = accentEvent.Text;
|
||||
|
||||
if (args.ObfuscatedMessage != null)
|
||||
{
|
||||
HandleWhisper(uid, args.Message, protoVoice);
|
||||
HandleWhisper(uid, message, protoVoice);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleSay(uid, args.Message, protoVoice);
|
||||
HandleSay(uid, message, protoVoice);
|
||||
}
|
||||
|
||||
private async void HandleSay(EntityUid uid, string message, TTSVoicePrototype voicePrototype)
|
||||
|
|
@ -269,3 +277,13 @@ public sealed class TransformSpeakerVoiceEvent : EntityEventArgs
|
|||
VoiceId = voiceId;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class TTSSanitizeEvent : EntityEventArgs
|
||||
{
|
||||
public string Text;
|
||||
|
||||
public TTSSanitizeEvent(string text)
|
||||
{
|
||||
Text = text;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue