
SpeechWave
The dynamic plot of the waveform that is displayed when you start acquiring speech
Displays the waveform plot
Demo
Via ShowUsedTime
Demo
Use the Show
value to control whether the waveform plot is displayed
Demo
Attributes
@page "/speechwaves"
@namespace BootstrapBlazor.Shared.Samples
@inject IStringLocalizer<SpeechWaves> Localizer
<h3>SpeechWave</h3>
<h4>The dynamic plot of the waveform that is displayed when you start acquiring speech</h4>
<DemoBlock Title="Basic usage" Introduction="Displays the waveform plot" Name="Normal">
<SpeechWave Show="@true" ShowUsedTime="false" />
</DemoBlock>
<DemoBlock Title="The length of the display" Introduction="Via <code>ShowUsedTime</code>" Name="ShowUsedTime">
<SpeechWave Show="@true" ShowUsedTime="true" />
</DemoBlock>
<DemoBlock Title="Parameters control whether it is displayed" Introduction="Use the <code>Show</code> value to control whether the waveform plot is displayed" Name="Value">
<div class="row g-3">
<div class="col-12">
<SpeechWave Show="IsShow" />
</div>
<div class="col-12">
<Button Text="@ButtonText" OnClick="OnClickShow"> </Button>
</div>
</div>
</DemoBlock>
<AttributeTable Items="@GetAttributes()" />
// Copyright (c) Argo Zhang (argo@163.com). All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
// Website: https://www.blazor.zone or https://argozhang.github.io/
namespace BootstrapBlazor.Shared.Samples;
/// <summary>
/// 语音识别波形图示例
/// </summary>
public partial class SpeechWaves
{
private bool IsShow { get; set; }
private string ButtonText => IsShow ? Localizer["ValueButtonText1"] : Localizer["ValueButtonText2"];
private void OnClickShow()
{
IsShow = !IsShow;
}
/// <summary>
/// 获得属性方法
/// </summary>
/// <returns></returns>
private IEnumerable<AttributeItem> GetAttributes() => new AttributeItem[]
{
// TODO: 移动到数据库中
new AttributeItem() {
Name = nameof(SpeechWave.Show),
Description = Localizer["ShowAttr"],
Type = "bool",
ValueList = "true/false",
DefaultValue = "false"
},
new AttributeItem() {
Name = nameof(SpeechWave.ShowUsedTime),
Description = Localizer["ShowUsedTimeAttr"],
Type = "bool",
ValueList = "true/false",
DefaultValue = "true"
},
new AttributeItem() {
Name = nameof(SpeechWave.OnTimeout),
Description = Localizer["OnTimeoutAttr"],
Type = "Func<Task>",
ValueList = " — ",
DefaultValue = " — "
},
new AttributeItem() {
Name = nameof(SpeechWave.TotalTime),
Description = Localizer["TotalTimeSecondAttr"],
Type = "int",
ValueList = " — ",
DefaultValue = "60000"
}
};
}