Skip to content

Commit

Permalink
RedFoxIV revie
Browse files Browse the repository at this point in the history
  • Loading branch information
Spatison committed Dec 5, 2024
1 parent 381938b commit 57f2866
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Content.Server/_White/TTS/TTSSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private async void OnRequestTTS(MsgRequestTTS ev)
if (textSanitized == "")
return null;

textSanitized = _ttsPitchRateSystem.TryGetPitchRate(uid, textSanitized, speechRate, speechPitch);
textSanitized = _ttsPitchRateSystem.GetFormattedSpeechText(uid, textSanitized, speechRate, speechPitch);
return await _ttsManager.ConvertTextToSpeech(speaker, textSanitized);
}
}
Expand Down
9 changes: 5 additions & 4 deletions Content.Shared/_White/TTS/TTSPitchRateSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public sealed class TTSPitchRateSystem : EntitySystem
["Reptilian"] = new TTSPitchRate("low", "slow"),
};

public string TryGetPitchRate(EntityUid? uid, string text, string? speechRate = null, string? speechPitch = null)
public string GetFormattedSpeechText(EntityUid? uid, string text, string? speechRate = null, string? speechPitch = null)
{
var ssml = text;
if (TryComp<HumanoidAppearanceComponent>(uid, out var humanoid))
{
var species = SpeciesPitches.GetValueOrDefault(humanoid.Species);
Expand All @@ -30,11 +31,11 @@ public string TryGetPitchRate(EntityUid? uid, string text, string? speechRate =
}

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

return $"<speak>{text}</speak>";
return $"<speak>{ssml}</speak>";
}
}

Expand Down

0 comments on commit 57f2866

Please sign in to comment.