Getting Started:
to get started, install the library and begin with this template
(note, in my testing, i had to restart the editor before it worked, so if it breaks please try that before reporting a bug)
template code:
Add a SharpTalkSpeaker component to any GameObject in the editor, then speak from code:
public sealed class MyComponent : Component
{
[Property] SharpTalkSpeaker Speaker { get; set; }
protected override void OnStart()
{
_ = Speaker.Speak( "Hello, world!" );
}
}Runtime Voice Switching:
Speaker.SetVoice( VoiceData.WhisperVoice );
_ = Speaker.Speak( "This is a whisper." );
Speaker.SetVoice( VoiceData.BaselineVoice );
_ = Speaker.Speak( "Back to normal." );
Lipsync:
OnPhoneme fires on the main thread as each phoneme begins playing, giving you a timeline to drive blend shapes, jaw bones, or any other animation:
Speaker.OnPhoneme += e =>
{
Log.Info( $"Phoneme {e.Phoneme} at {e.TimeSeconds:F3}s" );
// Drive a blend shape, animate a jaw bone, etc.
};
_ = Speaker.Speak( "Watch my mouth move." );