ApiApp() Functions

This class, implemented as part of the SILVIA C# API, provides access to SILVIA’s application interfaces. These interfaces are for applications to communicate with the SILVIA Core about application-specific data. For instance, the parent application can sample the SILVIA Core’s text output, and modify a TextBox that is visible to the user based on that sampling.

While you can define a “public SilviaCore” reference in external C# scripts by whatever name you choose, for all internal scripting, the Silvia Core is referred to as “_core”, e.g. “_core.ApiApp()…”

Discussion

The ApiApp() section covers some functions that would be run at application startup or upon loading a SILVIA Core, and some functions that may be changed or toggled throughout runtime. ApiApp() notably has methods for delegating out custom speech and setting the voice type and output, as well as methods that enable and disable the various SILVIA output stacks.

As an example, the SILVIA Studio Brain Controls Panel, where you can chat with the loaded SILVIA Core, calls a CheckChatListener method periodically during its update loop to poll whether the ApiApp().GetTextOutput stack has responses from SILVIA to display for the chat log. As follows:

Example Usage (C#)


private bool CheckChatListener() {
    if (_core == null) {
        return false;
    } else {
        string textOutput = null;
        string results = string.Empty;
        while (!string.IsNullOrEmpty(
            textOutput = _core.ApiApp().GetTextOutput())) {
            results += "" + OutputName.ToUpper() + ": " + textOutput;
        }
    }
return true;
}

The various FIFO output stacks available through ApiApp() include Text, Voice, Application Message, Diagnostic, and Socket. They can be enabled or disabled by commands hereinbelow.

Note: The Avatar System is being reimplemented for SILVIA Studio 3 and support for legacy Viseme functions is deprecated.

ApiApp()

This class, implemented as part of the SILVIA C# API, provides access to SILVIA’s application interfaces.

Function
Description
ApiApp().RegisterSetVoiceFontFunction
Delegates the speech output layer to a Plugin or Library, for handling custom or Non-Native TTS.
ApiApp().SetVoiceFont
Sets the Voice Font for output of AI Speech (TTS Delegate Needed).
ApiApp().SetVoiceType
Sets the type (TTS Provider) of the current Voice Font for speech (TTS Delegate Needed).
ApiApp().GetVoiceType
Returns the type (TTS Provider) of Voice Font for output of speech (TTS Delegate Needed).
ApiFeedback().SuggestFeedback
Adds Conceptual data to the Feedback memory as a suggestion.
ApiApp().GetVoiceFontGender
Gets the gender of the last successfully set Voice Font for output of speech (TTS Delegate Needed).
ApiApp().GetVoiceFontName
Gets the name of the last successfully set Voice Font for output of speech (TTS Delegate Needed).
ApiApp().GetVoiceFontRate
Gets the numeric rate of the last successfully set Voice font for output of speech (TTS Delegate Needed).
ApiApp().LoadVisemes*
*(Deprecated in 3.0) Loads Visemes for lip-synced animation from the given folder.
ApiApp().LoadVisemesCrop*
*(Deprecated in 3.0) Loads Visemes for lip-synced animation from the given folder, including a mouth cropping coefficient.
ApiApp().GetVisemesFolder*
*(Deprecated in 3.0) Returns the currently set Visemes folder for lip-synced animation.
ApiApp().EnableVoiceOutput
Enables or disables the attached voice output. (TTS Delegate or Native Speech)
ApiApp().VoiceOutputEnabled
Returns the enabled flag of the attached voice output.
ApiApp().EnableTextOutput
Enables or disables the attached text output.
ApiApp().TextOutputEnabled
Returns the enabled flag of the attached text output.
ApiApp().EnableSocketOutput
Enables or disables the attached socket output.
ApiApp().SocketOutputEnabled
Returns the enabled flag of the attached socket output.
ApiApp().EnableDiagOutput
Enables or disables the attached diagnostic output.
ApiApp().DiagOutputEnabled
Returns the enabled flag of the attached diagnostic output.
ApiApp().EnableApplicationMessage
Enables or disables the attached application message output.
ApiApp().ApplicationMessageEnabled
Returns the enabled flag of the attached application message output.
ApiApp().SetVoiceOutput
Set the voice output object’s text field for subsequent output.
ApiApp().GetVoiceOutput
Returns the first (FIFO) string in the voice output object.
ApiApp().GetApproximateSpeechLength
Measures the length of time to read a block of text at a given rate, returns an approximate float value in seconds. Audio-independent function.
ApiApp().IsSpeaking
Checks the status of the application’s voice output.
ApiApp().SetIsSpeaking
Forces an override of the status of the application’s voice output.
ApiApp().SetTextOutput
Pushes the output onto the text output object’s FIFO stack.
ApiApp().GetTextOutput
Returns the first string in the text output object’s FIFO stack.
ApiApp().ClearTextOutput
Clears the text output FIFO stack.
ApiApp().SetSocketOutput
Sends the string to the currently attached socket.
ApiApp().SetDiagOutput
Pushes the output onto the diagnostic output object’s FIFO stack.
ApiApp().GetDiagOutput
Returns the first string in the diagnostic output object’s FIFO stack.
ApiApp().ClearDiagOutput
Clears the diagnostic output FIFO stack.
ApiApp().SetApplicationMessage
Pushes the message output onto the application message object’s FIFO stack.
ApiApp().GetApplicationMessage
Returns the first string in the application message object’s FIFO stack.
ApiApp().ClearApplicationMessage
Clears the application message FIFO stack.
ApiApp().SetPagerTagsOutput
Pushes the output onto the PAGER Tags FIFO stack. Only send PAGER Tags.
ApiApp().GetPagerTagsOutput
Returns the first string of PAGER Tags FIFO stack.
ApiApp().ClearPagerTags
Clears the PAGER Tag output stack.
ApiApp().SetListening
Enables or disables the parent application’s speech recognition.
ApiApp().IsListening
Returns the boolean status of the parent application’s speech recognition.
ApiApp().ConsoleOut
Sends a text message to the SILVIA Studio debugging console, if available.