-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathServiceCollectionExtension.cs
More file actions
38 lines (32 loc) · 1.3 KB
/
ServiceCollectionExtension.cs
File metadata and controls
38 lines (32 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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/
using BootstrapBlazor.Components;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection;
/// <summary>
/// BootstrapBlazor 服务扩展类
/// </summary>
public static class ServiceCollectionExtension
{
/// <summary>
/// 增加 语音识别服务
/// </summary>
/// <param name="services"></param>
/// <param name="configOptions"></param>
/// <returns></returns>
public static IServiceCollection AddBootstrapBlazorBaiduSpeech(this IServiceCollection services, Action<
BaiduSpeechOption>? configOptions = null)
{
services.TryAddScoped<RecognizerService>();
services.AddScoped<IRecognizerProvider, BaiduRecognizerProvider>();
services.TryAddScoped<SynthesizerService>();
services.AddScoped<ISynthesizerProvider, BaiduSynthesizerProvider>();
services.AddOptionsMonitor<BaiduSpeechOption>();
services.Configure<BaiduSpeechOption>(option =>
{
configOptions?.Invoke(option);
});
return services;
}
}