/// <summary> /// 主页面 /// </summary> /// <returns></returns> public ActionResult Mainview() { try { string strUserId = Session["AccountID"].ToString(); int intUserId = Convert.ToInt32(strUserId); B_AccountTable accouunt = (from tbAccountTable in myDYXTEntities.B_AccountTable where tbAccountTable.AccountID == intUserId select tbAccountTable).Single(); ViewBag.User = accouunt.User; SpVoice speech = new SpVoice(); //new一个 int speechRate = -1; //语音朗读速度 int volume = 100; //音量 bool paused = false; //是否暂停 string testspeech = "You are welcome to use," + accouunt.User; //测试朗读内容 if (paused) { speech.Resume(); paused = false; } else { speech.Rate = speechRate; speech.Volume = volume; speech.Speak(testspeech, SpeechVoiceSpeakFlags.SVSFlagsAsync);//开始语音朗读 } return(View()); } catch (Exception e) { return(Redirect("/LoginMain/Login")); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { /*************************************************** * Userful resources for Country codes and SAPI XML fomat * https://msdn.microsoft.com/en-us/library/ms723602(v=vs.85).aspx * https://msdn.microsoft.com/en-us/library/ms717077(v=vs.85).aspx * https://msdn.microsoft.com/en-us/library/windows/desktop/dd318693(v=vs.85).aspx * https://msdn.microsoft.com/en-us/library/jj127898.aspx * /**************************************************/ voice.Volume = 100; // Volume (no xml) voice.Rate = 0; // Rate (no xml) voice.Speak("Fireball", SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechVoiceSpeakFlags.SVSFIsXML); /* * voice.Speak("<speak version='1.0' xmlns='http://www.w3.org/2001/10/synthesis' xml:lang='en-US'>" +"English One, two, three" +"<p xml:lang='it-IT'> Italiano uno, due, tre</p>" +"<p xml:lang='ja-JP'>日本語 一二三、終わります。 </p>" + "</speak>", + SpeechVoiceSpeakFlags.SVSFlagsAsync|SpeechVoiceSpeakFlags.SVSFIsXML); + + + voice.Speak("NOW XML SAPI TEST", SpeechVoiceSpeakFlags.SVSFlagsAsync); + + voice.Speak("Spelling: Chiaroscurist, <spell>Chiaroscurist.</spell>Normal Volume,<volume level='50'>Low volume</volume>", SpeechVoiceSpeakFlags.SVSFlagsAsync|SpeechVoiceSpeakFlags.SVSFIsXML); + voice.Speak("<lang langid='410'>Frase in italiano</lang>", SpeechVoiceSpeakFlags.SVSFlagsAsync|SpeechVoiceSpeakFlags.SVSFIsXML); + + + voice.Speak("ESTERNAL FILE READING TEST", SpeechVoiceSpeakFlags.SVSFlagsAsync); + + // voice.Speak(loadXMLStandalone ("builtIn.xml"), SpeechVoiceSpeakFlags.SVSFlagsAsync); + // voice.Speak(BuiltAsset, SpeechVoiceSpeakFlags.SVSFlagsAsync); + voice.Speak(loadXMLStandalone ("external.xml"), SpeechVoiceSpeakFlags.SVSFlagsAsync);//must in the resource folder after build + + voice.Speak("End of the test, enjoy this code", SpeechVoiceSpeakFlags.SVSFlagsAsync); */ } if (Input.GetKeyDown(KeyCode.P)) { voice.Pause(); } if (Input.GetKeyDown(KeyCode.R)) { voice.Resume(); } //TEST PER ANDROID /* if (Input.GetTouch) * { * * voice.Resume(); * }*/ }
private void btnpasuse_Click(object sender, EventArgs e) { if ("暂停".Equals(btnpasuse.Text)) { btnpasuse.Text = "继续"; speech.Pause(); } else { btnpasuse.Text = "暂停"; speech.Resume(); } }
private void _PauseBtn_Click(object sender, EventArgs e) { // 読み上げ中かどうかを判断 if (sv.Status.RunningState == SpeechRunState.SRSEIsSpeaking) { // 読み上げ中なら停止 sv.Pause(); } else { sv.Resume(); } }
private void btnSpeak_Click(object sender, System.EventArgs e) { if ((Convert.ToInt32(btnSpeak.Tag) == 0) && (sender != null)) { btnSpeak.Tag = 1; btnSpeak.Text = "STOP"; try { if (cbVoices.Text.Length > 0) { m_voice.Voice = m_voice.GetVoices(string.Format("Name={0}", cbVoices.Text), "Language=409").Item(0); } if (cbSaveToWave.Checked) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "All files (*.*)|*.*|wav files (*.wav)|*.wav"; sfd.Title = "Save to a wave file"; sfd.FilterIndex = 2; sfd.RestoreDirectory = true; if (sfd.ShowDialog() == DialogResult.OK) { SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite; SpFileStream SpFileStream = new SpFileStream(); SpFileStream.Open(sfd.FileName, SpFileMode, false); m_voice.AudioOutputStream = SpFileStream; m_voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync); m_voice.WaitUntilDone(Timeout.Infinite); SpFileStream.Close(); } } else { m_voice.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFlagsAsync); } } catch { MessageBox.Show("Speak error"); } } else { btnSpeak.Tag = 0; btnSpeak.Text = "SPEAK"; m_voice.Speak(null, (SpeechVoiceSpeakFlags)2); m_voice.Resume(); } }
// Update is called once per frame void Update() { if (intro) { StartCoroutine(startintro()); } if (intro1 && sm.task == 0) { StartCoroutine(startintro1()); } if (intro2 && sm.task == 0) { StartCoroutine(startintro2()); } if (intro3 && sm.task == 0) { StartCoroutine(startintro3()); } if (task1) { StartCoroutine(t1()); } if (task2) { StartCoroutine(t2()); } if (Input.GetKeyDown(KeyCode.P)) { voice.Pause(); } if (Input.GetKeyDown(KeyCode.R)) { voice.Resume(); } //TEST PER ANDROID /* if (Input.GetTouch) * { * * voice.Resume(); * }*/ }
private void button1_Click(object sender, EventArgs e) { if (paused) { paused = false; speech.Resume(); timer1.Start(); button1.Text = "PAUSE"; } else { paused = true; speech.Pause(); timer1.Stop(); button1.Text = "UNPAUSE"; } }
private void button1_Click(object sender, EventArgs e) { if (button1.Text == "开始播放(暂停中)") { button1.Text = "暂停播放(播放中)"; lab_startime.Text = "开始时间:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); PlayVoice(); timer1.Start(); _voice.Resume(); } else { button1.Text = "开始播放(暂停中)"; timer1.Stop(); _voice.Pause(); } }
private void SpeakText() { richTextBox1.ReadOnly = true; richTextBox1.Cursor = Cursors.No; status_label.Text = "Reading..."; if (!k) { sound.Resume(); k = true; } else { sound.Speak(text, SpeechVoiceSpeakFlags.SVSFDefault); EndStream(); } richTextBox1.ReadOnly = false; richTextBox1.Cursor = Cursors.IBeam; }
void Update() { if (Input.GetKeyDown(KeyCode.Q)) { //同步朗读(同步朗读时系统会停在这里,直到朗读完毕才会往下执行,建议使用异步朗读) voice.Speak("语音测试"); //异步朗读 voice.Speak(textfile.text, SpeechVoiceSpeakFlags.SVSFlagsAsync); } if (Input.GetKeyDown(KeyCode.W)) { //暂停使用该对象的所有朗读进程,同步朗读下无法使用该方法暂停 voice.Pause(); } if (Input.GetKeyDown(KeyCode.E)) { //恢复该对象所对应的被暂停的朗读进程 voice.Resume(); } }
public void Add(ParkInfoModel park, HttpPostedFileBase File) { try { if (!System.IO.Directory.Exists(Server.MapPath("/Img/"))) { System.IO.Directory.CreateDirectory(Server.MapPath("/Img/")); } park.PImage = Server.MapPath("/Img/") + File.FileName; park.TID = Convert.ToInt32(Request["TID"]); Session["TID"] = park.TID; HttpCookie http = Request.Cookies["Cooke"]; //Cooke解码 string str = HttpUtility.UrlDecode(http.Value, Encoding.GetEncoding("UTF-8")); //反序列化 List <ViewModel> models = JsonConvert.DeserializeObject <List <ViewModel> >(str); foreach (var a in models) { park.UIDa = a.UIDa; } url += "Park/Add"; string m = JsonConvert.SerializeObject(park); string i = HttpClientHeper.Post(url, m); if (Convert.ToInt32(i) > 0) { #region 语言播报 ////获取进入车辆的车牌号 //string phrase = Session["Plate"].ToString()+"欢迎进入"; ////语言播报的功能 //SpeechSynthesizer speech = new SpeechSynthesizer(); //CultureInfo keyboardCulture = System.Globalization.CultureInfo.GetCultureInfoByIetfLanguageTag("zh-cn"); //InstalledVoice neededVoice = speech.GetInstalledVoices(keyboardCulture).LastOrDefault(); //if (neededVoice == null) //{ // phrase = "Unsupported Language"; //} //else if (!neededVoice.Enabled) //{ // phrase = "Voice Disabled"; //} //else //{ // speech.SelectVoice(neededVoice.VoiceInfo.Name); //} //speech.Speak(phrase); //// using System.Speech.Synthesis; //SpeechSynthesizer synth = new SpeechSynthesizer(); //// Configure the audio output. //synth.SetOutputToDefaultAudioDevice(); //synth.Speak("请说一句话"); //synth.Speak(Session["Plate"].ToString() + "欢迎进入"); //// Speak a string. //synth.Speak("This example demonstrates a basic use of Speech Synthesizer"); //Console.WriteLine(); //Console.WriteLine("Press any key to exit..."); //Console.ReadKey(); #endregion //MVC SpVoice speech = new SpVoice(); //new一个 int speechRate = 1; //语音朗读速度 int volume = 100; //音量 bool paused = false; //是否暂停 string testspeech = Session["Plate"].ToString() + "欢迎进入"; //测试朗读内容 if (paused) { speech.Resume(); paused = false; } else { speech.Rate = speechRate; speech.Volume = volume; speech.Speak(testspeech, SpeechVoiceSpeakFlags.SVSFlagsAsync);//开始语音朗读 } #region 明细 Recode recode = new Recode(); string text = Session["Plate"].ToString() + "驶入汽车"; recode.RName = text; List <ViewModel> modelsa = JsonConvert.DeserializeObject <List <ViewModel> >(str); foreach (var t in models) { recode.FId = t.UIDa; } string urll = "http://localhost:6201/Recode/Add"; string y = JsonConvert.SerializeObject(recode); string model = HttpClientHeper.Post(urll, y); if (Convert.ToInt32(model) > 0) { Response.Redirect("http://localhost:7652/News/NewIndex"); } #endregion Response.Write("<script>alert('驶入成功!');location.href='/News/NewIndex'</script>"); } } catch (Exception) { Response.Write("<script>alert('请选择车辆图片!');location.href='/park/Add'</script>"); } }
public void Away(int id) { try { url += "Park/Away"; DateTime Leave = System.DateTime.Now; ParkInfoModel parks = new ParkInfoModel(); parks.ExpireDate = Leave; parks.PID = id; string model = JsonConvert.SerializeObject(parks); string m = HttpClientHeper.Post(url, model); if (Convert.ToInt32(m) > 0) { //MVC SpVoice speech = new SpVoice(); //new一个 int speechRate = 1; //语音朗读速度 int volume = 100; //音量 bool paused = false; //是否暂停 string testspeech = "感谢车牌号为" + Session["Plate"].ToString() + "的客户停车,祝您一路顺风"; //测试朗读内容 if (paused) { speech.Resume(); paused = false; } else { speech.Rate = speechRate; speech.Volume = volume; speech.Speak(testspeech, SpeechVoiceSpeakFlags.SVSFlagsAsync);//开始语音朗读 } DateTime Puttime = parks.CreateDate; DateTime Gettime = parks.ExpireDate; TimeSpan a = Gettime - Puttime; double b = a.Minutes / 60; int i = (int)Math.Ceiling(b); int ids = Convert.ToInt32(Session["TID"]); string urls = $"http://localhost:6201/CarType/CarSelectOne?id={ids}"; string o = HttpClientHeper.Get(urls); List <CarTypesInfoModel> list = JsonConvert.DeserializeObject <List <CarTypesInfoModel> >(o); decimal de = list.First().Tmaney; int price = Convert.ToInt32(de); int sum = i * price; Response.Write("<script>alert('谢谢您的本次停车!')</script>"); #region 明细 HttpCookie http = Request.Cookies["Cooke"]; //Cooke解码 string str = HttpUtility.UrlDecode(http.Value, Encoding.GetEncoding("UTF-8")); //反序列化 List <ViewModel> models = JsonConvert.DeserializeObject <List <ViewModel> >(str); Recode recode = new Recode(); string text = Session["Plate"].ToString() + "驶出汽车!¥" + sum + "元"; recode.RName = text; List <ViewModel> modelsa = JsonConvert.DeserializeObject <List <ViewModel> >(str); foreach (var t in modelsa) { recode.FId = t.UIDa; } string urll = "http://localhost:6201/Recode/Add"; string y = JsonConvert.SerializeObject(recode); string modela = HttpClientHeper.Post(urll, y); if (Convert.ToInt32(modela) > 0) { Response.Redirect("http://localhost:7652/Payment/QRcode?text=" + sum); } } } catch (Exception) { throw; } #endregion Response.Write("<script>alert('请去登入再做以下操作谢谢!');location.href='/UserInfo/UserInfoLogon'</script>"); }
public void Stop() { SpeakerSAPI5.Speak(null, (SpeechVoiceSpeakFlags)2); SpeakerSAPI5.Resume(); }