Skip to content

Class UTryllVoiceInputComponent

ClassList > UTryllVoiceInputComponent

More...

  • #include <TryllVoiceInputComponent.h>

Inherits the following classes: UActorComponent

Public Attributes

Type Name
float HotwordsScore = 1.5f
FTryllStoragePath HotwordsStoragePath
int32 MaxUtteranceMs = 60000
FTryllModelName ModelName = TEXT("Whisper Tiny EN (int8)")
FOnTryllVoiceError OnError
FOnTryllVoiceErrorDetailed OnErrorDetailed
FOnTryllTranscriptUpdate OnTranscriptUpdate
FOnTryllVoiceInputCreated OnVoiceInputCreated
UTryllAgentComponent * TargetAgent = nullptr
int32 VadMinSilenceMs = 1000
int32 VadSpeechPadMs = 250
float VadThreshold = 0.5f
bool bAutoFinishOnSilence = true
bool bCreateOnConnect = true

Public Functions

Type Name
void BeginUtterance (UTryllAgentComponent * AgentOverride=nullptr)
FTryllVoiceInputConfig BuildVoiceInputConfig (uint32 SampleRate) const
void CancelUtterance ()
void CreateVoiceInput ()
void DestroyVoiceInput ()
void EndUtterance ()
ETryllMicrophoneStatus GetMicrophoneStatus () const
FString GetMicrophoneStatusMessage () const
TSharedPtr< FTryllVoiceInput > GetVoiceInput () const
bool HasVoiceInput () const
bool IsMicrophoneUnavailable () const
bool IsUtteranceActive () const
UTryllVoiceInputComponent ()

Protected Functions

Type Name
virtual void BeginPlay () override
virtual void EndPlay (const EEndPlayReason::Type EndPlayReason) override
virtual void TickComponent (float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) override

Detailed Description

Actor component: owns one FTryllVoiceInput (STT) handle and drives it from the system microphone. The Unreal counterpart to the Unity TryllVoiceInputComponent.

Capture model: on-demand. The microphone opens on BeginUtterance() and closes when the final transcript arrives (or on End / Cancel). The component ticks to drain captured PCM and forward it to the server.

Audio: the device-native sample rate is declared to the server, which resamples to the STT model's expected rate. Multi-channel input is downmixed to mono. If the default device's rate changes under a live voice input, the next BeginUtterance recreates the voice input with the new rate (VoiceInputStarting).

Microphone check: CreateVoiceInput() and every BeginUtterance() first check that a default capture device exists. Without one the voice input is not created (no STT model is loaded), GetMicrophoneStatus() says why, one warning is logged, and each call raises OnErrorDetailed with ETryllErrorCode::MicrophoneUnavailable (except automatic creation, which may run before listeners bind: read GetMicrophoneStatus() at start-up). A later BeginUtterance() that finds a microphone creates the voice input and raises ETryllErrorCode::VoiceInputStarting for that call; so does one that finds the device's sample rate changed.

All delegates fire on the game thread.

Public Attributes Documentation

variable HotwordsScore

float UTryllVoiceInputComponent::HotwordsScore;

Logit-bias score applied to hotword tokens during decoding.


variable HotwordsStoragePath

FTryllStoragePath UTryllVoiceInputComponent::HotwordsStoragePath;

Plain string storage containing hotword / wake-word phrases (one per line). Relative to TryllRuntimeSettings::StorageDataFolder, e.g. "hotwords.txt". Leave empty to disable hotword boosting.


variable MaxUtteranceMs

int32 UTryllVoiceInputComponent::MaxUtteranceMs;

Hard timeout (ms) per utterance.


variable ModelName

FTryllModelName UTryllVoiceInputComponent::ModelName;

STT model — picked from the project's registered models (Model Manager).


variable OnError

FOnTryllVoiceError UTryllVoiceInputComponent::OnError;

Fired on every error, with its message only. OnErrorDetailed carries the code.


variable OnErrorDetailed

FOnTryllVoiceErrorDetailed UTryllVoiceInputComponent::OnErrorDetailed;

Fired on every error, together with OnError, with the full FTryllError so a handler can branch on Code (e.g. ETryllErrorCode::MicrophoneUnavailable).


variable OnTranscriptUpdate

FOnTryllTranscriptUpdate UTryllVoiceInputComponent::OnTranscriptUpdate;

Fired for each transcript update (partial and final).


variable OnVoiceInputCreated

FOnTryllVoiceInputCreated UTryllVoiceInputComponent::OnVoiceInputCreated;

Fired when the VoiceInput handle has been created.


variable TargetAgent

UTryllAgentComponent* UTryllVoiceInputComponent::TargetAgent;

Agent that receives the final transcript. Leave unset to auto-use the UTryllAgentComponent on the same actor (the common case — the details panel can't pick sibling components, so this resolves in BeginPlay). Put the Voice component on an actor with no agent for transcribe-only mode.


variable VadMinSilenceMs

int32 UTryllVoiceInputComponent::VadMinSilenceMs;

Silence duration (ms) that closes a speech segment.


variable VadSpeechPadMs

int32 UTryllVoiceInputComponent::VadSpeechPadMs;

Padding (ms) added around detected speech.


variable VadThreshold

float UTryllVoiceInputComponent::VadThreshold;

Silero VAD speech-probability threshold.


variable bAutoFinishOnSilence

bool UTryllVoiceInputComponent::bAutoFinishOnSilence;

Let server VAD close the utterance on silence (stop-on-silence mode).


variable bCreateOnConnect

bool UTryllVoiceInputComponent::bCreateOnConnect;

Create the VoiceInput handle automatically once the session is ready (connected + configured); queues until OnCreateSessionComplete if it spawns earlier. (Name kept for compatibility; it fires on session-ready, not raw connect.)


Public Functions Documentation

function BeginUtterance

void UTryllVoiceInputComponent::BeginUtterance (
    UTryllAgentComponent * AgentOverride=nullptr
) 

Open a new utterance and start microphone capture. A non-empty final transcript is sent through AgentOverride (or TargetAgent) unless that agent already has a turn in flight, in which case the transcript is dropped. Transcribe-only when both are null.


function BuildVoiceInputConfig

FTryllVoiceInputConfig UTryllVoiceInputComponent::BuildVoiceInputConfig (
    uint32 SampleRate
) const

CreateVoiceInput config from this component's inspector fields. SampleRate is the capture device rate declared to the server. Chat uses this so an "Actor component" source cannot drift from runtime.


function CancelUtterance

void UTryllVoiceInputComponent::CancelUtterance () 

Cancel the current utterance without producing a transcript.


function CreateVoiceInput

void UTryllVoiceInputComponent::CreateVoiceInput () 

Create the server-side VoiceInput handle. Ignored when one already exists. Without a microphone it broadcasts MicrophoneUnavailable instead.


function DestroyVoiceInput

void UTryllVoiceInputComponent::DestroyVoiceInput () 

Destroy the handle and release the server-side session.


function EndUtterance

void UTryllVoiceInputComponent::EndUtterance () 

Commit the current utterance (push-to-talk release).


function GetMicrophoneStatus

inline ETryllMicrophoneStatus UTryllVoiceInputComponent::GetMicrophoneStatus () const

Result of the last microphone check.


function GetMicrophoneStatusMessage

inline FString UTryllVoiceInputComponent::GetMicrophoneStatusMessage () const

Why the microphone is unavailable, readable as-is. Empty when it is not.


function GetVoiceInput

inline TSharedPtr< FTryllVoiceInput > UTryllVoiceInputComponent::GetVoiceInput () const

Live handle. Null until CreateVoiceInput completes.


function HasVoiceInput

bool UTryllVoiceInputComponent::HasVoiceInput () const

True once the server-side VoiceInput handle exists.


function IsMicrophoneUnavailable

bool UTryllVoiceInputComponent::IsMicrophoneUnavailable () const

True when the last check found no usable microphone (NoDevice or CaptureFailed).


function IsUtteranceActive

bool UTryllVoiceInputComponent::IsUtteranceActive () const

True while an utterance is open.


function UTryllVoiceInputComponent

UTryllVoiceInputComponent::UTryllVoiceInputComponent () 

Protected Functions Documentation

function BeginPlay

virtual void UTryllVoiceInputComponent::BeginPlay () override

function EndPlay

virtual void UTryllVoiceInputComponent::EndPlay (
    const EEndPlayReason::Type EndPlayReason
) override

function TickComponent

virtual void UTryllVoiceInputComponent::TickComponent (
    float DeltaTime,
    ELevelTick TickType,
    FActorComponentTickFunction * ThisTickFunction
) override


The documentation for this class was generated from the following file C:/_tryll/_monorepo3/tryll/clients/unreal/Source/TryllClient/Public/TryllVoiceInputComponent.h