menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class SfSpeechToText - Blazor API Reference | Syncfusion

    Show / Hide Table of Contents

    Class SfSpeechToText

    Inheritance
    System.Object
    SfBaseComponent
    SfSpeechToText
    Inherited Members
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    Namespace: Syncfusion.Blazor.Inputs
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class SfSpeechToText : SfBaseComponent

    Constructors

    SfSpeechToText()

    Declaration
    public SfSpeechToText()

    Properties

    AllowInterimResults

    Gets or sets a value indicating whether interim results should be provided in the SfSpeechToText component.

    Declaration
    public bool AllowInterimResults { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean indicating interim result provision. The default value is true.

    Remarks

    If set to true, partial transcription results are provided in real-time during speech recognition.

    ButtonSettings

    Gets or sets the configuration settings for the speech-to-text button in the SfSpeechToText component.

    Declaration
    public SpeechToTextButtonSettings ButtonSettings { get; set; }
    Property Value
    Type Description
    SpeechToTextButtonSettings

    A SpeechToTextButtonSettings object that defines the button’s appearance and behavior. The default value is a new instance of SpeechToTextButtonSettings.

    Remarks

    Use this property to customize the button’s content, icons, and position within the component.

    Created

    Event triggered when the SfSpeechToText component is fully initialized and ready for interaction.

    Declaration
    public EventCallback<object> Created { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.Object>

    This event is raised after the component has completed its setup and is ready to be used.

    Remarks

    Use this event to execute initialization logic, such as setting default values or updating the UI when the component is fully loaded.

    CssClass

    Gets or sets the CSS class for customizing the appearance of the SfSpeechToText component.

    Declaration
    public string CssClass { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the CSS class applied to the component. The default value is System.String.Empty.

    Remarks

    This property allows adding one or more custom CSS classes to modify the appearance of the component. It helps in styling the component to align with specific design requirements.

    Disabled

    Gets or sets a value indicating whether the SfSpeechToText component is disabled.

    Declaration
    public bool Disabled { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean representing the disabled state. The default value is false.

    Remarks

    When set to true, all interactions with the component, including starting and stopping speech recognition, are disabled. The component remains visible but does not respond to user actions.

    HtmlAttributes

    Gets or sets additional HTML attributes for the SfSpeechToText.

    Declaration
    public Dictionary<string, object> HtmlAttributes { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<System.String, System.Object>

    A dictionary containing the HTML attributes and their values.

    Remarks

    These attributes will be added to the HTML element of the SfSpeechToText component.

    Examples
    <SfSpeechToText HtmlAttributes=@CustomAttribute></SfSpeechToText>
    @code{
        Dictionary<string, object> CustomAttribute = new Dictionary<string, object>()
        {
            { "name", "speech-to-text" }
        };
    }

    ID

    Gets or sets the ID attribute for the SfSpeechToText component.

    Declaration
    public string ID { get; set; }
    Property Value
    Type Description
    System.String

    A string representing the unique identifier for the Audio Input. The default is System.String.Empty.

    Remarks

    This property allows you to specify a unique ID for the SfSpeechToText component. It can be useful for applying custom styles or accessing the component through scripts.

    Language

    Gets or sets the language and locale used for speech recognition in the SfSpeechToText component.

    Declaration
    public string Language { get; set; }
    Property Value
    Type Description
    System.String

    A System.String representing the language code. The default value is System.String.Empty.

    Remarks

    This ensures accurate transcription by selecting the appropriate language model for the recognized speech.

    Examples

    The following code demonstrates how to set the Language property in a Blazor component:

    
    
    
    

    ListeningState

    Gets or sets the current state of the speech-to-text recognition process.

    Declaration
    public SpeechToTextState ListeningState { get; set; }
    Property Value
    Type Description
    SpeechToTextState

    A SpeechToTextState value indicating the operational state of the component. The default value is Inactive.

    Remarks

    This property reflects whether the speech-to-text functionality is active, inactive, or in a transitional state. The available states are defined in the SpeechToTextState enumeration:

    • InactiveThe component is idle and not actively listening for speech input.
    • ListeningThe component is actively listening to audio and transcribing speech to text.
    • StoppedThe component has stopped listening for speech input, either manually or automatically.

    ShowTooltip

    Gets or sets a value indicating whether a tooltip should be displayed on hover in the SfSpeechToText.

    Declaration
    public bool ShowTooltip { get; set; }
    Property Value
    Type Description
    System.Boolean

    A System.Boolean that determines if the tooltip is shown. The default value is true.

    Remarks

    If set to true, the tooltip will be displayed to display additional information.

    SpeechRecognitionError

    Event triggered when an error occurs during speech recognition in the SfSpeechToText component.

    Declaration
    public EventCallback<SpeechRecognitionErrorEventArgs> SpeechRecognitionError { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SpeechRecognitionErrorEventArgs>

    This event is raised when an error is encountered in the speech recognition process.

    Remarks

    Use this event to handle errors that occur during speech recognition, providing feedback or troubleshooting information.

    SpeechRecognitionStarted

    Event triggered when speech recognition starts in the SfSpeechToText component.

    Declaration
    public EventCallback<SpeechRecognitionStartedEventArgs> SpeechRecognitionStarted { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SpeechRecognitionStartedEventArgs>

    This event is raised when the speech recognition process begins.

    Remarks

    Use this event to handle logic when speech recognition starts, such as changing UI indicators or notifying the user that speech input is being processed.

    SpeechRecognitionStopped

    Event triggered when speech recognition stops in the SfSpeechToText component.

    Declaration
    public EventCallback<SpeechRecognitionStoppedEventArgs> SpeechRecognitionStopped { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<SpeechRecognitionStoppedEventArgs>

    This event is raised when the speech recognition process has been stopped.

    Remarks

    Use this event to handle logic when speech recognition stops, such as saving the transcript or updating the UI to indicate that speech input has ended.

    TooltipSettings

    Gets or sets the tooltip configuration for the SfSpeechToText component.

    Declaration
    public SpeechToTextTooltipSettings TooltipSettings { get; set; }
    Property Value
    Type Description
    SpeechToTextTooltipSettings

    A SpeechToTextTooltipSettings object that defines the tooltip’s content, position, and behavior. The default value is a new instance of SpeechToTextTooltipSettings.

    Remarks

    Tooltips provide helpful descriptions or guidance for button actions, improving accessibility and user experience.

    Transcript

    Gets or sets the transcribed text from the speech recognition process in the SfSpeechToText component.

    Declaration
    public string Transcript { get; set; }
    Property Value
    Type Description
    System.String

    A System.String containing the transcribed text. The default value is System.String.Empty.

    Remarks

    This property supports two-way data binding using the @bind-Transcript directive in Blazor. It dynamically updates during speech recognition, providing both interim and final transcription results.

    Examples

    The following code demonstrates how to set the Transcript property in a Blazor component:

    <SfSpeechToText Transcript="CurrentTranscript" />
    @code {
        private string CurrentTranscript = string.Empty;
    }

    TranscriptChanged

    Gets or sets an event callback that is raised when the Transcript property is changed.

    Declaration
    public EventCallback<string> TranscriptChanged { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<System.String>

    An event call back function.

    TranscriptChanging

    Event triggered when the recognized transcript is being updated in real-time during speech recognition.

    Declaration
    public EventCallback<TranscriptChangeEventArgs> TranscriptChanging { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.EventCallback<TranscriptChangeEventArgs>

    This event is raised whenever the recognized text is modified before final confirmation.

    Remarks

    This event is fired when the speech recognition engine detects new words or adjusts the existing transcript. It enables tracking live changes to the recognized text before the final result is confirmed, making it useful for real-time display updates.

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    OnAfterRenderAsync(Boolean)

    Declaration
    protected override Task OnAfterRenderAsync(bool firstRender)
    Parameters
    Type Name Description
    System.Boolean firstRender
    Returns
    Type
    System.Threading.Tasks.Task
    Overrides
    SfBaseComponent.OnAfterRenderAsync(Boolean)

    OnInitializedAsync()

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type
    System.Threading.Tasks.Task
    Overrides
    SfBaseComponent.OnInitializedAsync()

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type
    System.Threading.Tasks.Task

    StartListeningAsync()

    Starts the speech recognition process asynchronously in the SfSpeechToText component.

    Declaration
    public Task StartListeningAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Remarks

    This method initiates speech recognition, allowing the SfSpeechToText component to start listening for speech input.

    StopListeningAsync()

    Stops the speech recognition process asynchronously in the SfSpeechToText component.

    Declaration
    public Task StopListeningAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task

    A System.Threading.Tasks.Task representing the asynchronous operation.

    Remarks

    Use this method to stop the speech recognition process and release any resources associated with it in the SfSpeechToText component.

    Back to top Generated by DocFX
    Copyright © 2001 - 2025 Syncfusion Inc. All Rights Reserved