Skip to content

Commit

Permalink
TTS fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison committed Dec 4, 2024
1 parent adf604a commit 381938b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions Content.Shared/_White/TTS/TTSPitchRateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ public sealed class TTSPitchRateSystem : EntitySystem

public string TryGetPitchRate(EntityUid? uid, string text, string? speechRate = null, string? speechPitch = null)
{
if (!TryComp<HumanoidAppearanceComponent>(uid, out var humanoid))
return $"<speak>{text}</speak>";

var species = SpeciesPitches.GetValueOrDefault(humanoid.Species);
if (species == null)
return $"<speak>{text}</speak>";
if (TryComp<HumanoidAppearanceComponent>(uid, out var humanoid))
{
var species = SpeciesPitches.GetValueOrDefault(humanoid.Species);
if (species != null)
{
speechRate ??= species.Rate;
speechPitch ??= species.Pitch;
}
}

if (speechRate != null)
text = $"<prosody rate=\"{species.Rate}\">{text}</prosody>";
text = $"<prosody rate=\"{speechRate}\">{text}</prosody>";
if (speechPitch != null)
text = $"<prosody pitch=\"{species.Pitch}\">{text}</prosody>";
text = $"<prosody pitch=\"{speechPitch}\">{text}</prosody>";

return $"<speak>{text}</speak>";
}
Expand Down

0 comments on commit 381938b

Please sign in to comment.