mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-11 19:31:12 +03:00
Fix tts settings (#1774)
This commit is contained in:
parent
02725c0882
commit
49dedfbef2
2 changed files with 25 additions and 4 deletions
|
|
@ -24,6 +24,16 @@ public sealed class TTSSystem : EntitySystem
|
|||
private readonly MemoryContentRoot _contentRoot = new();
|
||||
private static readonly ResPath Prefix = ResPath.Root / "TTS";
|
||||
|
||||
/// <summary>
|
||||
/// Reducing the volume of the TTS when whispering. Will be converted to logarithm.
|
||||
/// </summary>
|
||||
private const float WhisperFade = 4f;
|
||||
|
||||
/// <summary>
|
||||
/// The volume at which the TTS sound will not be heard.
|
||||
/// </summary>
|
||||
private const float MinimalVolume = -10f;
|
||||
|
||||
private float _volume = 0.0f;
|
||||
private int _fileIdx = 0;
|
||||
|
||||
|
|
@ -56,15 +66,14 @@ public sealed class TTSSystem : EntitySystem
|
|||
{
|
||||
_sawmill.Debug($"Play TTS audio {ev.Data.Length} bytes from {ev.SourceUid} entity");
|
||||
|
||||
var volume = _volume;
|
||||
if (ev.IsWhisper)
|
||||
volume -= 4;
|
||||
var volume = AdjustVolume(ev.IsWhisper);
|
||||
|
||||
var filePath = new ResPath($"{_fileIdx++}.ogg");
|
||||
_contentRoot.AddOrUpdateFile(filePath, ev.Data);
|
||||
|
||||
var audioParams = AudioParams.Default.WithVolume(volume);
|
||||
var soundPath = new SoundPathSpecifier(Prefix / filePath, audioParams);
|
||||
|
||||
if (ev.SourceUid != null)
|
||||
{
|
||||
var sourceUid = GetEntity(ev.SourceUid.Value);
|
||||
|
|
@ -77,4 +86,16 @@ public sealed class TTSSystem : EntitySystem
|
|||
|
||||
_contentRoot.RemoveFile(filePath);
|
||||
}
|
||||
|
||||
private float AdjustVolume(bool isWhisper)
|
||||
{
|
||||
var volume = MinimalVolume + SharedAudioSystem.GainToVolume(_volume);
|
||||
|
||||
if (isWhisper)
|
||||
{
|
||||
volume -= SharedAudioSystem.GainToVolume(WhisperFade);
|
||||
}
|
||||
|
||||
return volume;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
- type: ttsVoice
|
||||
- type: ttsVoice
|
||||
id: Aidar
|
||||
name: tts-voice-name-aidar
|
||||
sex: Male
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue