Merge pull request #362 from frosty-dev/tts_xrenoidUpdate
[Feat] TTS 15 new voices + effects
This commit is contained in:
@@ -55,7 +55,7 @@ public sealed class TTSManager
|
|||||||
/// <param name="text">SSML formatted text</param>
|
/// <param name="text">SSML formatted text</param>
|
||||||
/// <returns>OGG audio bytes</returns>
|
/// <returns>OGG audio bytes</returns>
|
||||||
/// <exception cref="Exception">Throws if url or token CCVar not set or http request failed</exception>
|
/// <exception cref="Exception">Throws if url or token CCVar not set or http request failed</exception>
|
||||||
public async Task<byte[]?> ConvertTextToSpeech(string speaker, string text, string pitch, string rate)
|
public async Task<byte[]?> ConvertTextToSpeech(string speaker, string text, string pitch, string rate, string? effect = null)
|
||||||
{
|
{
|
||||||
var url = _cfg.GetCVar(WhiteCVars.TtsApiUrl);
|
var url = _cfg.GetCVar(WhiteCVars.TtsApiUrl);
|
||||||
var maxCacheSize = _cfg.GetCVar(WhiteCVars.TtsMaxCacheSize);
|
var maxCacheSize = _cfg.GetCVar(WhiteCVars.TtsMaxCacheSize);
|
||||||
@@ -78,7 +78,8 @@ public sealed class TTSManager
|
|||||||
Text = text,
|
Text = text,
|
||||||
Speaker = speaker,
|
Speaker = speaker,
|
||||||
Pitch = pitch,
|
Pitch = pitch,
|
||||||
Rate = rate
|
Rate = rate,
|
||||||
|
Effect = effect
|
||||||
};
|
};
|
||||||
|
|
||||||
var request = CreateRequestLink(url, body);
|
var request = CreateRequestLink(url, body);
|
||||||
@@ -132,6 +133,9 @@ public sealed class TTSManager
|
|||||||
query["rate"] = body.Rate;
|
query["rate"] = body.Rate;
|
||||||
query["file"] = "1";
|
query["file"] = "1";
|
||||||
query["ext"] = "ogg";
|
query["ext"] = "ogg";
|
||||||
|
if (body.Effect != null)
|
||||||
|
query["effect"] = body.Effect;
|
||||||
|
|
||||||
uriBuilder.Query = query.ToString();
|
uriBuilder.Query = query.ToString();
|
||||||
return uriBuilder.ToString();
|
return uriBuilder.ToString();
|
||||||
}
|
}
|
||||||
@@ -164,6 +168,9 @@ public sealed class TTSManager
|
|||||||
|
|
||||||
[JsonPropertyName("rate")]
|
[JsonPropertyName("rate")]
|
||||||
public string Rate { get; set; } = default!;
|
public string Rate { get; set; } = default!;
|
||||||
|
|
||||||
|
[JsonPropertyName("effect")]
|
||||||
|
public string? Effect { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct GenerateVoiceResponse
|
private struct GenerateVoiceResponse
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public sealed partial class TTSSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var message = FormattedMessage.RemoveMarkup(ev.Message);
|
var message = FormattedMessage.RemoveMarkup(ev.Message);
|
||||||
var soundData = await GenerateTTS(null, message, ttsPrototype.Speaker);
|
var soundData = await GenerateTTS(null, message, ttsPrototype.Speaker, speechRate: "slow", effect: "announce");
|
||||||
|
|
||||||
if (soundData == null)
|
if (soundData == null)
|
||||||
return;
|
return;
|
||||||
@@ -211,7 +211,7 @@ public sealed partial class TTSSystem : EntitySystem
|
|||||||
_ttsManager.ResetCache();
|
_ttsManager.ResetCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<byte[]?> GenerateTTS(EntityUid? uid, string text, string speaker, string? speechPitch = null, string? speechRate = null)
|
private async Task<byte[]?> GenerateTTS(EntityUid? uid, string text, string speaker, string? speechPitch = null, string? speechRate = null, string? effect = null)
|
||||||
{
|
{
|
||||||
var textSanitized = Sanitize(text);
|
var textSanitized = Sanitize(text);
|
||||||
if (textSanitized == "")
|
if (textSanitized == "")
|
||||||
@@ -238,7 +238,7 @@ public sealed partial class TTSSystem : EntitySystem
|
|||||||
rate = speechRate;
|
rate = speechRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
return await _ttsManager.ConvertTextToSpeech(speaker, textSanitized, pitch, rate);
|
return await _ttsManager.ConvertTextToSpeech(speaker, textSanitized, pitch, rate, effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,3 +39,18 @@ tts-voice-name-sheogorath = Шеогорат
|
|||||||
tts-voice-name-turret-floor = Турель
|
tts-voice-name-turret-floor = Турель
|
||||||
tts-voice-name-cirilla = Цири
|
tts-voice-name-cirilla = Цири
|
||||||
tts-voice-name-lambert = Ламберт
|
tts-voice-name-lambert = Ламберт
|
||||||
|
tts-voice-name-polina = Полина
|
||||||
|
tts-voice-name-arthas = Артас
|
||||||
|
tts-voice-name-xrenoid = Хреноид
|
||||||
|
tts-voice-name-azir = Азир
|
||||||
|
tts-voice-name-caitlyn = Кэйтлин
|
||||||
|
tts-voice-name-ekko = Экко
|
||||||
|
tts-voice-name-twitch = Твич
|
||||||
|
tts-voice-name-strelok = Стрелок
|
||||||
|
tts-voice-name-ziggs = Зиггс
|
||||||
|
tts-voice-name-tracer = Трейсер
|
||||||
|
tts-voice-name-illidan = Иллидан
|
||||||
|
tts-voice-name-rexxar = Рексар
|
||||||
|
tts-voice-name-voljin = Вол'джин
|
||||||
|
tts-voice-name-forester = Лесник
|
||||||
|
tts-voice-name-sidorovich = Сидорович
|
||||||
|
|||||||
@@ -254,3 +254,93 @@
|
|||||||
name: tts-voice-name-lambert
|
name: tts-voice-name-lambert
|
||||||
sex: Male
|
sex: Male
|
||||||
speaker: lambert
|
speaker: lambert
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Polina
|
||||||
|
name: tts-voice-name-polina
|
||||||
|
sex: Female
|
||||||
|
speaker: polina
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Arthas
|
||||||
|
name: tts-voice-name-arthas
|
||||||
|
sex: Male
|
||||||
|
speaker: arthas
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Xrenoid
|
||||||
|
name: tts-voice-name-xrenoid
|
||||||
|
sex: Male
|
||||||
|
speaker: xrenoid
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Azir
|
||||||
|
name: tts-voice-name-azir
|
||||||
|
sex: Male
|
||||||
|
speaker: azir
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Caitlyn
|
||||||
|
name: tts-voice-name-caitlyn
|
||||||
|
sex: Female
|
||||||
|
speaker: caitlyn
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Ekko
|
||||||
|
name: tts-voice-name-ekko
|
||||||
|
sex: Male
|
||||||
|
speaker: ekko
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Twitch
|
||||||
|
name: tts-voice-name-twitch
|
||||||
|
sex: Male
|
||||||
|
speaker: twitch
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Strelok
|
||||||
|
name: tts-voice-name-strelok
|
||||||
|
sex: Male
|
||||||
|
speaker: strelok
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Ziggs
|
||||||
|
name: tts-voice-name-ziggs
|
||||||
|
sex: Male
|
||||||
|
speaker: ziggs
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Tracer
|
||||||
|
name: tts-voice-name-tracer
|
||||||
|
sex: Female
|
||||||
|
speaker: tracer
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Illidan
|
||||||
|
name: tts-voice-name-illidan
|
||||||
|
sex: Male
|
||||||
|
speaker: illidan
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Rexxar
|
||||||
|
name: tts-voice-name-rexxar
|
||||||
|
sex: Male
|
||||||
|
speaker: rexxar
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Voljin
|
||||||
|
name: tts-voice-name-voljin
|
||||||
|
sex: Male
|
||||||
|
speaker: voljin
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Forester
|
||||||
|
name: tts-voice-name-forester
|
||||||
|
sex: Male
|
||||||
|
speaker: forester
|
||||||
|
|
||||||
|
- type: ttsVoice
|
||||||
|
id: Sidorovich
|
||||||
|
name: tts-voice-name-sidorovich
|
||||||
|
sex: Male
|
||||||
|
speaker: sidorovich
|
||||||
|
|||||||
Reference in New Issue
Block a user