Class TrRealtimeTask
Builder class for configuring and executing realtime translation tasks.
Inherited Members
Namespace: Glitch9.AIDevKit.Sheets.Realtime
Assembly: Glitch9.AIDevKit.Sheets.dll
Syntax
public class TrRealtimeTask
Constructors
| Edit this page View SourceTrRealtimeTask(string)
Initializes a new realtime translation task with the text to translate.
Declaration
public TrRealtimeTask(string textToTranslate)
Parameters
| Type | Name | Description |
|---|---|---|
| string | textToTranslate | The text to translate |
Methods
| Edit this page View SourceSetCallback(Action<string>)
Sets the callback to be invoked when translation is completed.
Declaration
public TrRealtimeTask SetCallback(Action<string> onTranslated)
Parameters
| Type | Name | Description |
|---|---|---|
| Action<string> | onTranslated | The callback function that receives the translated text |
Returns
| Type | Description |
|---|---|
| TrRealtimeTask | The current instance for method chaining |
SetModel(Model)
Sets the AI model to use. If not provided, the default model will be used.
Declaration
public TrRealtimeTask SetModel(Model model)
Parameters
| Type | Name | Description |
|---|---|---|
| Model | model | The AI model |
Returns
| Type | Description |
|---|---|
| TrRealtimeTask | The current instance for method chaining |
SetService(TrService)
Sets the translation service to use.
Declaration
public TrRealtimeTask SetService(TrService service)
Parameters
| Type | Name | Description |
|---|---|---|
| TrService | service | The translation service |
Returns
| Type | Description |
|---|---|
| TrRealtimeTask | The current instance for method chaining |
SetSourceLocale(Locale)
Sets the source language. If not provided, the source language will be detected automatically.
Declaration
public TrRealtimeTask SetSourceLocale(Locale sourceLocale)
Parameters
| Type | Name | Description |
|---|---|---|
| Locale | sourceLocale | The source language |
Returns
| Type | Description |
|---|---|
| TrRealtimeTask | The current instance for method chaining |
SetTargetLocale(Locale)
Sets the target language. If not provided, the target language will be set to the default locale.
Declaration
public TrRealtimeTask SetTargetLocale(Locale targetLocale)
Parameters
| Type | Name | Description |
|---|---|---|
| Locale | targetLocale | The target language |
Returns
| Type | Description |
|---|---|
| TrRealtimeTask | The current instance for method chaining |
TrAsync()
Executes the translation asynchronously with the configured settings.
Declaration
public UniTask<string> TrAsync()
Returns
| Type | Description |
|---|---|
| UniTask<string> | The translated text |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown when realtime translation is disabled |