From 24095d15bac3015fb13745a4769341c5c4f0187c Mon Sep 17 00:00:00 2001 From: lilium-saber Date: Tue, 7 Nov 2023 20:00:59 +0800 Subject: [PATCH] voice 11072001 Signed-off-by: lilium-saber --- ...pulatedInThisFileAndCallThroughFunction.cs | 40 +++++++++---------- src/translationKey/yieldVoice.cs | 32 +++++++++++++++ src/需要添加部分.txt | 36 ----------------- 3 files changed, 50 insertions(+), 58 deletions(-) create mode 100644 src/translationKey/yieldVoice.cs delete mode 100644 src/需要添加部分.txt diff --git a/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs b/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs index 4149d67..f85f544 100644 --- a/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs +++ b/src/AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction.cs @@ -1,13 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using System.Collections.Generic; using WpfApp2.ScnToJson; using WpfApp2.translationKey; using WpfApp2.transToNet; +using WpfApp2.tools; +using WpfApp2.tools.translationKey; -namespace WpfApp2 +namespace WpfApp2.tools { internal class AllClassAndInterfaceWellBeManipulatedInThisFileAndCallThroughFunction { @@ -19,6 +17,7 @@ namespace WpfApp2 TranslationScnToJson scnjson = new TranslationScnToJson(); Messiah jsonnet = new jsonNet(); TempResource temp = new TempResource(); + yieldVoice voice = new yieldVoice(); public void InputPrivateBaidu(string name, string id, string key) { @@ -30,16 +29,6 @@ namespace WpfApp2 trin.InPutPrivate(name, list); } - public bool OutExistsD() - { - return trstr.GetExistsD(); - } - - public bool OutExistsF(string name) - { - return trstr.GetExistsF(name); - } - public List OutputNameList() { List list = trstr.OutputTranslationNameList(); @@ -67,11 +56,14 @@ namespace WpfApp2 { scnjson.StopTrans(spa, dps); } - public string NetBaiDu(string input) { return jsonnet.RequestJsonBaiDu(input); } + public string NetBaiDu(string input, List list) + { + return jsonnet.RequestJsonBaiDu(input, list); + } public string NetAllBaiDu(string input, string srcl, string dstl, string aid, string kkey) { @@ -87,6 +79,10 @@ namespace WpfApp2 { return jsonnet.RequestJsonXunFei(input); } + public string NetXunFei(string input, List list) + { + return jsonnet.RequestJsonXunFei(input, list); + } public string NetLanXunFei(string input, string srcl, string dstl) { @@ -119,7 +115,7 @@ namespace WpfApp2 } public void SetDst(string dst) - { + { temp.TempDstSet(dst); } @@ -158,10 +154,10 @@ namespace WpfApp2 return temp.TempChoicGet(); } - - + public void OutPutVoice(string text, string lan) + { + voice.CreateVoice(text, lan); + } } } - - diff --git a/src/translationKey/yieldVoice.cs b/src/translationKey/yieldVoice.cs new file mode 100644 index 0000000..2768119 --- /dev/null +++ b/src/translationKey/yieldVoice.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.Windows; +using Windows.Media.SpeechSynthesis; +using System.Speech.Synthesis; + +namespace WpfApp2.tools.translationKey +{ + internal class yieldVoice// + { + private string language = "zh-CN"; + + public async void CreateVoice(string temp, string lan) + { + await Task.Delay(TimeSpan.FromSeconds(1));//延迟1s + var syn = new System.Speech.Synthesis.SpeechSynthesizer(); + var bui = new PromptBuilder(); + syn.SetOutputToDefaultAudioDevice(); + lan ??= language; + bui.StartVoice(new System.Globalization.CultureInfo(lan)); + bui.AppendText(temp); + bui.EndVoice(); + syn.Speak(bui); + } + + + } +} diff --git a/src/需要添加部分.txt b/src/需要添加部分.txt deleted file mode 100644 index c486617..0000000 --- a/src/需要添加部分.txt +++ /dev/null @@ -1,36 +0,0 @@ - -ڣ - - - - - - - - - private void TransSourceSelectWnd_loaded(object sender, RoutedEventArgs e) - { - var window = new TranslationSourceSelect(); - window.ShowDialog(); - } - private void PrograssSelectWnd_loaded(object sender, RoutedEventArgs e) - { - var window = new ProgressSelect(); - window.ShowDialog(); - } - private void TransSourceInWindow(object sender, RoutedEventArgs e) - { - var window = new TransSourceInWindow(); - window.ShowDialog(); - } - private void TransSourceSelectPri(object sender, RoutedEventArgs e) - { - var windows = new TransSourceSelectPri(); - windows.ShowDialog(); - } -