From 8c2f63ea87517e4455a4bb38e29c623cf836e921 Mon Sep 17 00:00:00 2001 From: argo-iMac Date: Tue, 10 Jan 2023 20:43:16 +0800 Subject: [PATCH 1/7] =?UTF-8?q?refactor:=20=E5=A2=9E=E5=8A=A0=E8=AF=AD?= =?UTF-8?q?=E9=80=9F=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BaiduSynthesizerProvider.cs | 45 +++++++++++-------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs index 8f8c35587..a59f388d0 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs @@ -60,28 +60,35 @@ public class BaiduSynthesizerProvider : ISynthesizerProvider, IAsyncDisposable } Interop ??= DotNetObjectReference.Create(this); - if (Option.MethodName == "bb_baidu_speech_synthesizerOnce" && !string.IsNullOrEmpty(Option.Text)) + switch (Option.MethodName) { - var result = Client.Synthesis(Option.Text); - if (result.Success) + case "bb_baidu_speech_synthesizerOnce" when !string.IsNullOrEmpty(Option.Text): { - await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback), result.Data); + var result = Client.Synthesis(Option.Text, new Dictionary() + { + { "spd", 6 } + }); + if (result.Success) + { + await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback), result.Data); + } + else + { + + } + Logger.LogInformation($"bb_baidu_speech_synthesizerOnce {result.Success}"); + if (!result.Success) + { + Logger.LogError($"{result.ErrorCode}: {result.ErrorMsg}"); + } + + break; } - else - { - - } - Logger.LogInformation($"bb_baidu_speech_synthesizerOnce {result.Success}"); - if (!result.Success) - { - Logger.LogError($"{result.ErrorCode}: {result.ErrorMsg}"); - } - } - else if (Option.MethodName == "bb_baidu_close_synthesizer") - { - // 停止语音 - await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback)); - Logger.LogInformation("bb_baidu_close_synthesizer"); + case "bb_baidu_close_synthesizer": + // 停止语音 + await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback)); + Logger.LogInformation("bb_baidu_close_synthesizer"); + break; } } -- Gitee From 7edfe12965426fec4298a1b59d52627f06ebdb83 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Tue, 10 Jan 2023 20:47:20 +0800 Subject: [PATCH 2/7] =?UTF-8?q?refactor:=20=E7=B2=BE=E7=AE=80=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BaiduSynthesizerProvider.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs index a59f388d0..6340e0dfe 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs @@ -114,11 +114,8 @@ public class BaiduSynthesizerProvider : ISynthesizerProvider, IAsyncDisposable { if (disposing) { - if (Interop != null) - { - Interop.Dispose(); - } - if (Module is not null) + Interop?.Dispose(); + if (Module != null) { await Module.DisposeAsync(); } -- Gitee From 124a91185625d34fd51f8cd41187fe8d4a9da7ca Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Tue, 10 Jan 2023 20:47:41 +0800 Subject: [PATCH 3/7] =?UTF-8?q?refactor:=20=E6=9B=B4=E6=94=B9=E4=B8=BA=20s?= =?UTF-8?q?witch?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BaiduSynthesizerProvider.cs | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs index 6340e0dfe..ef8377ae6 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs @@ -63,27 +63,27 @@ public class BaiduSynthesizerProvider : ISynthesizerProvider, IAsyncDisposable switch (Option.MethodName) { case "bb_baidu_speech_synthesizerOnce" when !string.IsNullOrEmpty(Option.Text): - { - var result = Client.Synthesis(Option.Text, new Dictionary() + { + var result = Client.Synthesis(Option.Text, new Dictionary() { { "spd", 6 } }); - if (result.Success) - { - await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback), result.Data); - } - else - { - + if (result.Success) + { + await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback), result.Data); + } + else + { + + } + Logger.LogInformation($"bb_baidu_speech_synthesizerOnce {result.Success}"); + if (!result.Success) + { + Logger.LogError($"{result.ErrorCode}: {result.ErrorMsg}"); + } + + break; } - Logger.LogInformation($"bb_baidu_speech_synthesizerOnce {result.Success}"); - if (!result.Success) - { - Logger.LogError($"{result.ErrorCode}: {result.ErrorMsg}"); - } - - break; - } case "bb_baidu_close_synthesizer": // 停止语音 await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback)); -- Gitee From a7012e6792d9f36899c5b60154b1885343a3b671 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Tue, 10 Jan 2023 20:57:55 +0800 Subject: [PATCH 4/7] =?UTF-8?q?refactor:=20=E6=B6=88=E9=99=A4=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BaiduSynthesizerProvider.cs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs index ef8377ae6..7ea122607 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs @@ -55,7 +55,7 @@ public class BaiduSynthesizerProvider : ISynthesizerProvider, IAsyncDisposable if (Module == null) { var moduleName = "./_content/BootstrapBlazor.BaiduSpeech/js/synthesizer.js"; - Logger.LogInformation($"load module {moduleName}"); + Logger.LogInformation("load module {moduleName}", moduleName); Module = await JSRuntime.InvokeAsync("import", moduleName); } Interop ??= DotNetObjectReference.Create(this); @@ -72,16 +72,11 @@ public class BaiduSynthesizerProvider : ISynthesizerProvider, IAsyncDisposable { await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback), result.Data); } - else - { - - } - Logger.LogInformation($"bb_baidu_speech_synthesizerOnce {result.Success}"); + Logger.LogInformation("bb_baidu_speech_synthesizerOnce {result}", result.Success); if (!result.Success) { - Logger.LogError($"{result.ErrorCode}: {result.ErrorMsg}"); + Logger.LogError("{ErrorCode}: {ErrorMsg}", result.ErrorCode, result.ErrorMsg); } - break; } case "bb_baidu_close_synthesizer": -- Gitee From d27bf35dc369b4437912909f66737cc2eed8e274 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Tue, 10 Jan 2023 20:58:14 +0800 Subject: [PATCH 5/7] =?UTF-8?q?doc:=20=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/BaiduSynthesizerProvider.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs index 7ea122607..d78c7d15c 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/Services/BaiduSynthesizerProvider.cs @@ -65,9 +65,9 @@ public class BaiduSynthesizerProvider : ISynthesizerProvider, IAsyncDisposable case "bb_baidu_speech_synthesizerOnce" when !string.IsNullOrEmpty(Option.Text): { var result = Client.Synthesis(Option.Text, new Dictionary() - { - { "spd", 6 } - }); + { + { "spd", SpeechOption.Speed } + }); if (result.Success) { await Module.InvokeVoidAsync(Option.MethodName, Interop, nameof(Callback), result.Data); -- Gitee From 124d6004499d76d67d9c0f7c657478aef7e4b8fd Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Tue, 10 Jan 2023 20:58:57 +0800 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E8=AF=AD?= =?UTF-8?q?=E9=80=9F=E6=8E=A7=E5=88=B6=E9=85=8D=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BootstrapBlazor.BaiduSpeech/BaiduSpeechOption.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BaiduSpeechOption.cs b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BaiduSpeechOption.cs index 4bad542b1..181634d5a 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BaiduSpeechOption.cs +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BaiduSpeechOption.cs @@ -26,4 +26,9 @@ public class BaiduSpeechOption /// [NotNull] public string? Secret { get; set; } + + /// + /// 获得/设置 语速 值范围 0 - 9 默认值 5 + /// + public int Speed { get; set; } = 5; } -- Gitee From 297e1522fa67eba5466bdb87b6fa398401baf538 Mon Sep 17 00:00:00 2001 From: Argo-Asicotech Date: Tue, 10 Jan 2023 20:59:26 +0800 Subject: [PATCH 7/7] chore: bump version 7.1.0 --- .../BootstrapBlazor.BaiduSpeech.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BootstrapBlazor.BaiduSpeech.csproj b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BootstrapBlazor.BaiduSpeech.csproj index c3d52a292..5fa568ded 100644 --- a/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BootstrapBlazor.BaiduSpeech.csproj +++ b/src/Extensions/Components/BootstrapBlazor.BaiduSpeech/BootstrapBlazor.BaiduSpeech.csproj @@ -1,7 +1,7 @@ - 7.0.0 + 7.1.0 -- Gitee