TextToSpeech/Lilith.TextToSpeech.cscsharp

Documentation

Lilith (Version 2)

Version 2 Lilith agent library. Entry point: Lilith.cs with partials under Boot/, Chat/, Ollama/, and SystemPrompt/.

Build the solution or run python ../Build-v2.py from this tree.

using Agent.Core.Logging;using Agent.Core.TextToSpeech;namespace Lilith.Agent;public partial class Lilith{    private KokoroTts? _textToSpeech;    /// <summary>Enable Kokoro TTS after each assistant reply.</summary>    public void UseTextToSpeech(KokoroTts textToSpeech)    {        _textToSpeech = textToSpeech ?? throw new ArgumentNullException(nameof(textToSpeech));    }    private async Task SpeakReplyAsync(string? reply)    {        if (_textToSpeech is null || string.IsNullOrWhiteSpace(reply))        {            return;        }        try        {            await _textToSpeech.SpeakAsync(reply).ConfigureAwait(false);        }        catch (Exception ex)        {            Logger.WriteLine("TTS", $"Speech failed: {ex.Message}", LogColors.Orange);        }    }}