/** * Export to tts engine * Copyright (C) David Futcher 2007 * <bobbocanfly at gmail dot com> * http://text2speech.sourceforge.net * This function is part of Text2Speech. */ public void export(string q, string a, string file) { if (Settings.getBool ("dumpTooltips") == false) { return; } int pause = Settings.getInt ("speakingPauseInt", 5) * 1000; file = this.sanitizeFilename (file) + ".wav"; SpVoice expVoice = new SpVoice (); SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite; SpFileStream SpFileStream = new SpFileStream (); SpFileStream.Open (file, SpFileMode, false); expVoice.AudioOutputStream = SpFileStream; expVoice.Volume = 100; expVoice.Rate = 0; expVoice.Speak ("<speak/><volume level=\"0\">a<volume level=\"100\"><silence msec=\"2000\"/>", SpeechVoiceSpeakFlags.SVSFDefault); expVoice.Speak ("<speak/>" + q, SpeechVoiceSpeakFlags.SVSFDefault); expVoice.Speak ("<speak/><volume level=\"0\">a<volume level=\"100\"><silence msec=\"" + pause.ToString () + "\"/>", SpeechVoiceSpeakFlags.SVSFDefault); expVoice.Speak ("<speak/>" + a, SpeechVoiceSpeakFlags.SVSFDefault); expVoice.Speak ("<speak/><volume level=\"0\">a<volume level=\"100\"><silence msec=\"2000\"/>", SpeechVoiceSpeakFlags.SVSFDefault); SpFileStream.Close (); expVoice = null; }
public void Run() { var speaker = new SpVoice(); VoiceType = NeoSpeechVoiceType.Anna; speaker.Voice = NeoSpeech.GetVoice(VoiceType); speaker.Rate = Rate; SpFileStream stream = new SpFileStream(); try { stream.Format.Type = SpeechAudioFormatType.SAFT48kHz16BitStereo; stream.Open(FileName + ".wav", SpeechStreamFileMode.SSFMCreateForWrite, true); speaker.AudioOutputStream = stream; speaker.Speak(Text,SpeechVoiceSpeakFlags.SVSFlagsAsync); speaker.WaitUntilDone(Timeout.Infinite); stream.Close(); Thread.Sleep(100); MP3Engine.Wav2Mp3(FileName + ".wav", FileName + ".mp3"); System.IO.File.Delete(FileName + ".wav"); } catch (System.Runtime.InteropServices.COMException ex) { stream.Close(); throw ex; } finally { } }
/// <summary>Speaks the specified text to the specified file.</summary> /// <param name="text">The text to be spoken.</param> /// <param name="audioPath">The file to which the spoken text should be written.</param> /// <remarks>Uses the Microsoft Speech libraries.</remarks> private void SpeakToFile(string text, FileInfo audioPath) { SpFileStream spFileStream = new SpFileStream(); try { // Create the speech engine and set it to a random installed voice SpVoice speech = new SpVoice(); ISpeechObjectTokens voices = speech.GetVoices(string.Empty, string.Empty); speech.Voice = voices.Item(NextRandom(voices.Count)); // Set the format type to be heavily compressed. This both decreases download // size and increases distortion. SpAudioFormatClass format = new SpAudioFormatClass(); format.Type = SpeechAudioFormatType.SAFTGSM610_11kHzMono; spFileStream.Format = format; // Open the output stream for the file, speak to it, and wait until it's complete spFileStream.Open(audioPath.FullName, SpeechStreamFileMode.SSFMCreateForWrite, false); speech.AudioOutputStream = spFileStream; speech.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync); speech.Rate = -5; speech.WaitUntilDone(System.Threading.Timeout.Infinite); } finally { // Close the output file spFileStream.Close(); } }
static void Main(string[] args) { SpeechVoiceSpeakFlags flags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice v = new SpVoice(); if( args.Length > 0 ) { v.Speak(args[0], flags); } else { v.Speak("Please specify what you would like me to say.", flags ); } v.WaitUntilDone(Timeout.Infinite); }
protected void Button1_Click() { //THIS BLOCK WORKS RIGHT SpVoice ob = new SpVoice(); ob.Rate = -100; ob.Speak("Start recognistion", SpeechVoiceSpeakFlags.SVSFDefault); SpStream str = new SpStream(); }
public void Speek() { Console.WriteLine("This test should play a sound."); SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFDefault; var speech = new SpVoice(); speech.Speak("You are being followed", SpFlags); //speech.Speak("You are were eaten by a Grue", SpFlags); }
public void OnPingTimeOut(string serverName) { SpVoice speech = new SpVoice(); for (int i=0; i<(int)warningVoiceUpDown.Value; i++) { speech.Speak(string.Format("{0} {1}",serverName, voiceTextBox.Text), SpeechVoiceSpeakFlags.SVSFlagsAsync); } }
private void Falar01(int velocidade, int volume, string mensagem) { // Cria o objeto SpVoice speak = new SpVoice(); // Define a velocidade speak.Rate = velocidade; // Define o volume speak.Volume = volume; // Pede uma requisição para falar speak.Speak(mensagem, SpeechVoiceSpeakFlags.SVSFDefault); //Se você deixar essa linha, o texto falará apenas quando terminar o método (método Assíncrono) speak.WaitUntilDone(speak.SynchronousSpeakTimeout); }
public static void GetJobVoice(string job) { Thread.Sleep(10); if (MainWin.TitleLinks.FirstOrDefault(l => l.Source == new Uri("cmd://GoSound", UriKind.Absolute))? .DisplayName != "Выключить звук" || job == null) return; if (Voice != null) { Voice.Pause(); Voice = null; } Voice = new SpVoice(); Voice.Speak(job, (SpeechVoiceSpeakFlags)65); }
public static string Speek(string word) { string url; if (!CheckWord(word, out url)) { var path = HttpContext.Current.Server.MapPath(url); var voice = new SpVoice(); voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); var sp = new SpFileStream(); sp.Open(path, SpeechStreamFileMode.SSFMCreateForWrite); voice.AudioOutputStream = sp; voice.Speak(word); voice.WaitUntilDone(System.Threading.Timeout.Infinite); sp.Close(); } return url; }
static void Main(string[] args) { SpVoice voice = new SpVoice(); string esc = "n"; do { Console.WriteLine("Napisz tekst do przeczytania"); string command = Console.ReadLine(); voice.Speak(command, SpeechVoiceSpeakFlags.SVSFlagsAsync); Console.WriteLine("Zakończ: 't' - tak 'n' - nie"); esc = Console.ReadLine(); } while (esc != "t"); //Obdzekt o = new Obdzekt(); //o.cos = 3; //o.nazwa = "macin"; //Console.WriteLine(o.nazwa); //Console.WriteLine(o.cos); ////o.JakasMetoda("NIE macin"); ////o.Foo(2); ////o.Bar(o); ////Metody.Foo(o); ////Obdzekt oo = Metody.Bar(o); ////Obdzekt oo = Metody.Clone(o); //Obdzekt oo = Metody.Clone2(o); //Console.WriteLine(oo.nazwa); //Console.WriteLine(oo.cos); //oo.nazwa = "cycki"; //oo.cos = 1500100900; //Console.WriteLine(oo.nazwa); //Console.WriteLine(oo.cos); //Console.ReadKey(true); }
/** * Speak balloon tip */ public void SpeakBalloonTip(string q, string a, bool speak) { if (!speak) { return; } int pause = Settings.getInt ("speakingPauseInt", 5) * 1000; SpVoice _voice = new SpVoice (); _voice.Speak ("<speak/>" + q, SpeechVoiceSpeakFlags.SVSFDefault); _voice.Speak ("<speak/><volume level=\"0\">a<volume level=\"100\"><silence msec=\"" + pause.ToString () + "\"/>", SpeechVoiceSpeakFlags.SVSFDefault); _voice.Speak ("<speak/>" + a, SpeechVoiceSpeakFlags.SVSFDefault); _voice = null; try { this.export (q, a, q); } catch (Exception ex) { MessageBox.Show ("Error: " + ex.Message); return; } GC.Collect (); }
private void btSave_Click(object sender, EventArgs e) { if(txtSpeach.Text == "") { CustomMessageBox.CustomMessageBox.Show("文本无内容,无法保存","错误",CustomMessageBox.CustomMessageBox.MsgBoxButtons.OK,CustomMessageBox.CustomMessageBox.MsgBoxIcons.Error); return; } else { saveFileDialog1.FileName = ""; saveFileDialog1.Filter = "无损音乐格式(*.wav)|*.wav"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { SpVoice spv = new SpVoice(); if (spv == null) return; SpFileStream cpFileStream = new SpFileStream(); cpFileStream.Open(saveFileDialog1.FileName, SpeechStreamFileMode.SSFMCreateForWrite, false); spv.AudioOutputStream = cpFileStream; spv.Voice = spv.GetVoices(string.Empty, string.Empty).Item(cmbVoices.SelectedIndex); spv.Volume = trVolume.Value; spv.Speak(txtSpeach.Text, SpeechVoiceSpeakFlags.SVSFDefault); cpFileStream.Close(); System.IO.FileInfo f = new System.IO.FileInfo(saveFileDialog1.FileName); if (File.Exists(saveFileDialog1.FileName)) { CustomMessageBox.CustomMessageBox.Show(f.Name + " 保存成功", "提示", CustomMessageBox.CustomMessageBox.MsgBoxButtons.OK, CustomMessageBox.CustomMessageBox.MsgBoxIcons.Info); } else { CustomMessageBox.CustomMessageBox.Show(f.Name + " 保存失败", "警告", CustomMessageBox.CustomMessageBox.MsgBoxButtons.OK, CustomMessageBox.CustomMessageBox.MsgBoxIcons.Error); } } } }
private void start_Speak() { SpVoice spv = new SpVoice(); if (spv == null) return; spv.Voice = spv.GetVoices(string.Empty, string.Empty).Item(cmbVoices.SelectedIndex); spv.Volume = trVolume.Value; spv.Speak(txtSpeach.Text, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); if (closeFlag == 0) { CustomMessageBox.CustomMessageBox.Show("文本阅读完毕", "提示", CustomMessageBox.CustomMessageBox.MsgBoxButtons.OK, CustomMessageBox.CustomMessageBox.MsgBoxIcons.Info); } if (speak_Thread.IsAlive) { speak_Thread.Abort(); speak_Thread.Join(); speak_Thread = null; } }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); // Display the drawing using our image control Image.Source = this.imageSource; SpVoice Voice = new SpVoice(); Voice.Speak("Hello! Welcome to Kinect with Ergonomics!"); // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit (See components in Toolkit Browser). foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; // break; } } if (null != this.sensor) { // Turn on the color stream to receive color frames this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30); // Allocate space to put the pixels we'll receive this.colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength]; // This is the bitmap we'll display on-screen this.colorBitmap = new WriteableBitmap(this.sensor.ColorStream.FrameWidth, this.sensor.ColorStream.FrameHeight, 96.0, 96.0, PixelFormats.Bgr32, null); // Set the image we display to point to the bitmap where we'll put the image data this.Image2.Source = this.colorBitmap; // Add an event handler to be called whenever there is new color frame data this.sensor.ColorFrameReady += this.SensorColorFrameReady; // Turn on the skeleton stream to receive skeleton frames this.sensor.SkeletonStream.Enable(); // Add an event handler to be called whenever there is new color frame data this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady; // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; } } if (null == this.sensor) { this.statusBarText.Text = Properties.Resources.NoKinectReady; } }
private void SpeakWithMicrosoftSpeechLibrary(string textToSpeak, Action onComplete, int?volume, int?rate, string voice) { var voiceToUse = voice ?? Settings.Default.SpeechVoice; if (!string.IsNullOrWhiteSpace(voiceToUse)) { if (!legacySpeechMode) { try { speechSynthesiser.SelectVoice(voiceToUse); speechSynthesiser.Rate = rate ?? Settings.Default.SpeechRate; speechSynthesiser.Volume = volume ?? Settings.Default.SpeechVolume; } catch (Exception exception) { var customException = new ApplicationException(string.Format(Resources.UNABLE_TO_SET_VOICE_WARNING, voiceToUse, voice == null ? Resources.VOICE_COMES_FROM_SETTINGS : null), exception); PublishError(this, customException); Log.Info("Switching to legacy speech mode and trying again..."); legacySpeechMode = true; } } if (legacySpeechMode) { Log.Info("Attempting speech using legacy mode."); try { if (legacySpeechSynthesiser == null) { //Lazy instantiate legacy speech synthesiser legacySpeechSynthesiser = new SpVoice(); } var availableVoices = legacySpeechSynthesiser.GetVoices(string.Empty, string.Empty); if (legacyVoiceToTokenIndexLookup.ContainsKey(voiceToUse)) { int voiceIndex = legacyVoiceToTokenIndexLookup[voiceToUse]; Log.InfoFormat($"{voiceToUse} voice token exists at index {voiceIndex}. Setting voice on legacy speech synthesiser."); legacySpeechSynthesiser.Voice = availableVoices.Item(voiceIndex); Log.Info("Voice token set."); } else { for (int voiceIndex = 0; voiceIndex < availableVoices.Count; voiceIndex++) { var voiceToken = availableVoices.Item(voiceIndex); if (voiceToken.GetDescription() == voiceToUse) { Log.InfoFormat($"{voiceToUse} voice token found at index {voiceIndex}. Setting voice on legacy speech synthesiser."); legacyVoiceToTokenIndexLookup.Add(voiceToUse, voiceIndex); legacySpeechSynthesiser.Voice = voiceToken; Log.Info("Voice token set."); break; } } } } catch (Exception exception) { var customException = new ApplicationException(string.Format(Resources.UNABLE_TO_SET_VOICE_WARNING, voiceToUse, voice == null ? Resources.VOICE_COMES_FROM_SETTINGS : null), exception); PublishError(this, customException); } } } //Speak if (!legacySpeechMode) { onSpeakCompleted = (sender, args) => { lock (speakCompletedLock) { if (onSpeakCompleted != null) { speechSynthesiser.SpeakCompleted -= onSpeakCompleted; onSpeakCompleted = null; } if (onComplete != null) { onComplete(); } } }; speechSynthesiser.SpeakCompleted += onSpeakCompleted; speechSynthesiser.SpeakAsync(textToSpeak); } else { //Legacy speech mode if (legacySpeechSynthesiser != null) { legacySpeechSynthesiser.Speak(textToSpeak, SpeechVoiceSpeakFlags.SVSFIsNotXML | SpeechVoiceSpeakFlags.SVSFlagsAsync); var speechHandle = legacySpeechSynthesiser.SpeakCompleteEvent(); var speechHandlePtr = new IntPtr(speechHandle); if (speechHandlePtr != IntPtr.Zero) { var autoResetEvent = new AutoResetEvent(false) { SafeWaitHandle = new SafeWaitHandle(speechHandlePtr, false) }; var uiThreadDispatcher = Dispatcher.CurrentDispatcher; legacySpeakCompleted = (state, timedOut) => { if (onComplete != null) { uiThreadDispatcher.Invoke(onComplete); } autoResetEvent.Dispose(); legacySpeakCompleted = null; }; ThreadPool.RegisterWaitForSingleObject(autoResetEvent, legacySpeakCompleted, null, 30000, true); } } } }
/// <summary> /// Speaks the provided text out load /// </summary> /// <param name="text"></param> public void Speak(string text) { SpVoice voice = new SpVoice(); voice.Speak(text, SpeechVoiceSpeakFlags.SVSFDefault); }
private void start_Speak() { SpVoice spv = new SpVoice(); if (spv == null) return; spv.Voice = spv.GetVoices(string.Empty, string.Empty).Item(cmbVoices.SelectedIndex); spv.Volume = 100; spv.Speak("警告!!检测到可自执行文件,建议使用U盘防护扫描", SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); }
// private void btnPronounce_Click(object sender, EventArgs e) { //voice1.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault); voice1.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFNLPSpeakPunc); }
//Hàm phát âm một từ tiếng Anh private void btnSpeakEnglish_Click(object sender, EventArgs e) { SpVoice phatam = new SpVoice(); phatam.Speak(cbWord.Text, SpeechVoiceSpeakFlags.SVSFDefault); }
//okutma fonksiyonu void Speech(string text) { SpVoice oku = new SpVoice(); oku.Speak(text, SpeechVoiceSpeakFlags.SVSFDefault); }
void SpeakPlayerList() { spVoice.Skip("Sentence", int.MaxValue); spVoice.Speak(PlayerList.Instance.text.text); }
/// <summary> /// 播放语音 /// </summary> /// <param name="text"></param> private void Speak(string text) { Voice.Speak(text, SpeechVoiceSpeakFlags.SVSFlagsAsync); }
private void button2_Click(object sender, EventArgs e) { SpVoice Speaker = new SpVoice(); Speaker.Speak(textBox1.Text, SpeechVoiceSpeakFlags.SVSFDefault); }
private void btnListen_Click(object sender, EventArgs e) { SpVoice ses = new SpVoice(); ses.Speak(richTextBox1.Text); }
private void btnTTS_Click(object sender, RoutedEventArgs e) { voice.Rate = (int)this.sliderRate.Value; voice.Speak("测试成功", SpeechVoiceSpeakFlags.SVSFlagsAsync); }
static bool say(string filename, string sent, SpVoice voice) { SpFileStream fileStream = null; bool success = true; try { SpeechVoiceSpeakFlags flags = SpeechVoiceSpeakFlags.SVSFIsXML; //SpeechVoiceSpeakFlags flags = SpeechVoiceSpeakFlags.SVSFIsNotXML; //SpVoice voice = new SpVoice(); SpeechStreamFileMode fileMode = SpeechStreamFileMode.SSFMCreateForWrite; fileStream = new SpFileStream(); fileStream.Open(filename, fileMode, false); // audio output /* voice.Speak(sent, flags); voice.WaitUntilDone(Timeout.Infinite); */ // file output voice.AudioOutputStream = fileStream; voice.Speak(sent, flags); voice.WaitUntilDone(Timeout.Infinite); } catch (Exception error) { success = false; Console.Error.WriteLine("Error speaking sentence: " + error); Console.Error.WriteLine("error.Data: " + error.Data); Console.Error.WriteLine("error.HelpLink: " + error.HelpLink); } finally { if (fileStream != null) { fileStream.Close(); } } return success; }
public void Speak(string value) { _voice.Speak(value, SpeechVoiceSpeakFlags.SVSFlagsAsync); }
protected void clickToSpeech_Click(object sender, EventArgs e) { SpVoice objspeech = new SpVoice(); objspeech.Speak(prathyusha.Text.Trim(), SpeechVoiceSpeakFlags.SVSFDefault); objspeech.WaitUntilDone(System.Threading.Timeout.Infinite); }
//button5生成读音 private void button5_Click(object sender, RoutedEventArgs e) { //数据库全部读出 WordLogic[] wordList = WordLogic.FindAll(); SpFileStream SpFileStream = new SpFileStream(); String fileName; SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpeechStreamFileMode SpFileMode = SpeechStreamFileMode.SSFMCreateForWrite; SpVoice voice = new SpVoice(); // prepare voice SpObjectTokenCategory aotc = new SpObjectTokenCategory(); aotc.SetId(SpeechLib.SpeechStringConstants.SpeechCategoryVoices); foreach (ISpeechObjectToken token in aotc.EnumerateTokens()) { if (token.GetDescription() == "VW Julie") { englishToken = (SpObjectToken)token; } else if (token.GetDescription() == "VW Hui") { chineseToken = (SpObjectToken)token; } } voice.Voice = englishToken; voice.Rate = -4; String outFolderPath = Directory.GetParent("../../TestCases/") + @"\单词音频\"; if (!Directory.Exists(outFolderPath)) { Directory.CreateDirectory(outFolderPath); } for (int i = 0; i < wordList.Length; i++) { String word = wordList[i].word; if (word != null) { word = word.Trim(); } if (String.IsNullOrEmpty(word)) { // 遇到无效内容,退出 continue; } word = convert(word); fileName = outFolderPath + word + ".wav"; SpFileStream.Open(fileName, SpFileMode, false); voice.AudioOutputStream = SpFileStream; voice.Speak(word, SpFlags); voice.WaitUntilDone(Timeout.Infinite); SpFileStream.Close(); } MessageBox.Show("音频生成完毕!"); }
private void msgTimer_Tick(object sender, EventArgs e) { try { //显示的字数长度 int length = (int)((msgStartX - msgCurntX) / (msgStep * 4)); if (ExtendAppContext.Current.StaticMsgList == null) { ExtendAppContext.Current.StaticMsgList = new List <string>(); ExtendAppContext.Current.StaticMsgList.Add("暂无公告信息。"); } string msg = ""; //非紧急公告,即静态公告 if (!isEmgrcMsg) { if (msgIndex == ExtendAppContext.Current.StaticMsgList.Count) { msgIndex = 0; msgCurntX = msgStartX; } msg = ExtendAppContext.Current.StaticMsgList[msgIndex]; //修正起始位置偏移的问题 while ((length <= msg.Length) && (this.CreateGraphics().MeasureString(msg.Substring(0, length), MsgFont).Width < (msgStartX - msgCurntX))) { length++; } if (length > ExtendAppContext.Current.StaticMsgList[msgIndex].Length) { length = ExtendAppContext.Current.StaticMsgList[msgIndex].Length; } //截取需要显示的字符串 curntMsg = ExtendAppContext.Current.StaticMsgList[msgIndex].Substring(0, length); } else { //修正起始位置偏移的问题 while ((length <= noticeMsg.Length) && (this.CreateGraphics().MeasureString(noticeMsg.Substring(0, length), MsgFont).Width < (msgStartX - msgCurntX))) { length++; } if (length > noticeMsg.Length) { length = noticeMsg.Length; } //截取需要显示的字符串 curntMsg = noticeMsg.Substring(0, length); } //计算需要显示的字符长度 int msgLength = (int)this.CreateGraphics().MeasureString(curntMsg, MsgFont).Width; if (msgCurntX + msgLength > 0) { screenBottomPnl.Refresh(); msgCurntX -= msgStep; } //转完一圈,重新获取公告信息 if (msgCurntX + msgLength <= 0) { //msgTimer.Stop(); if (!isEmgrcMsg) { //重新获取静态播报信息列表 QueryParams queryParams = new QueryParams(); queryParams.AddQueryDefines("ScreenNo", OperationEnum.Equal, ExtendAppContext.Current.CurntScreenNo); DataTable staticMsgTable = DataOperator.HttpWebApi <DataResult>(ApiUrlEnum.GetValidMsgData, queryParams).ToDataTable(); List <string> staticListMsg = new List <string>(); if (staticMsgTable != null && staticMsgTable.Rows.Count > 0) { foreach (DataRow row in staticMsgTable.Rows) { if (!row.IsNull("MSG_CONTENT") && !string.IsNullOrEmpty(row["MSG_CONTENT"].ToString())) { staticListMsg.Add(row["MSG_CONTENT"].ToString()); } } ExtendAppContext.Current.StaticMsgList = staticListMsg; } msgIndex++; } //Dictionary<string, string> noticeMsgDict = GetMsgNoticInfo(); if (noticeMsgDict.Count > 0 && ExtendAppContext.Current.IsBroadCast) { isEmgrcMsg = true; foreach (KeyValuePair <string, string> kvp in noticeMsgDict) { string[] Info_Count = kvp.Value.Split(',');//通告信息,播报次数 string msgID = kvp.Key; noticeMsg = Info_Count[0]; int count = Convert.ToInt32(Info_Count[1]); SpFlags = DotNetSpeech.SpeechVoiceSpeakFlags.SVSFlagsAsync; Voice = new SpVoice(); Voice.Rate = -4; Voice.Speak(noticeMsg, SpFlags); //Voice.WaitUntilDone(System.Threading.Timeout.Infinite); //可播报次数-1 count -= 1; //更新剩余可播报次数 UpdateMsgDataTable(msgID, count); if (count == 0) { noticeMsgDict.Remove(msgID); } else { noticeMsgDict[msgID] = noticeMsg + "," + count; } // noticeMsgDict.Add(msgID, noticeMsg + "," + count); break;//一次只播一条 } } else { isEmgrcMsg = false; } msgCurntX = msgStartX; //msgTimer.Start(); } } catch (Exception ex) { ExceptionHandler.Handle(ex); } }
private void timer1_Tick(object sender, EventArgs e) { //textBox2.Text = Clipboard.GetText(); SetWindow SetWin = new xiaoyuan1._0.SetWindow(this.Handle); SetWin.Star(); textBox2.Text = Clipboard.GetText(); //if (xydo.textbox2 == 0) //{ // textBox2.Visible = false; // pictureBox3.Focus(); // xydo.textbox2 = 1; //} //if (xydo.textbox2 == 2) //{ // textBox2.Visible = true; // pictureBox3.Focus(); // xydo.textbox2 = 1; //} if (xylt.open == 1) { textBox3.Visible = true; textBox3.Focus(); } if (xylt.open == 0) { textBox3.Visible = false; } if (xydo.textbox == 0) { textBox1.Visible = false; pictureBox3.Focus(); xydo.textbox = 1; } if (xydo.textbox == 2) { textBox1.Visible = true; textBox1.Focus(); label4.Visible = false; xydo.textbox = 1; } if (textBox1.Text == "") { this.timer2.Enabled = false; } if (textBox3.Text == "") { this.timer5.Enabled = false; } if (textBox1.Text.Contains("哦") || textBox1.Text.Contains("哦!")) { textBox1.Text = textBox1.Text.Replace("哦!", ""); textBox1.Text = textBox1.Text.Replace("哦", ""); textBox1.Text = textBox1.Text.Replace("!", ""); } if (cyk.cymlzt == 1) { if (Clipboard.GetText() == "不执行" || Clipboard.GetText().Contains("不执行") || Clipboard.GetText().Contains("不")) { xyzt.open = 2; if (xyzt.open == 2) { xyzt.open = 0; cyk.cymlzt = 0; if (Clipboard.GetText() != "") { Clipboard.Clear(); //清空剪切板内容 } keybd_event(0x71, 0, 0, 0); //按F2 Random shuiji = new Random(); Image image = pictureBox3.BackgroundImage; pictureBox3.BackgroundImage = Image.FromFile(@".\\UI\表情\" + shuiji.Next(1, 6) + ".png"); string[] word = File.ReadAllLines(@".\\yuyinku\7.txt", System.Text.Encoding.Default); label1.Text = word[shuiji.Next(0, word.Length)]; voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); voice.Speak(word[shuiji.Next(0, word.Length)]); keybd_event(0x71, 0, 0, 0);//按F2 //pictureBox3.BackgroundImage = image; } } else { if (Clipboard.GetText() == "执行" || Clipboard.GetText() == "好" || Clipboard.GetText() == "可以")//听到用户说确定 { xyzt.open = 2; if (xyzt.open == 2) { xyzt.open = 0; cyk.cymlzt = 0; Process.Start(cyk.cyml(cyk.cymlnr)); keybd_event(0x71, 0, 0, 0);//按F2 Random shuiji = new Random(); Image image = pictureBox3.BackgroundImage; pictureBox3.BackgroundImage = Image.FromFile(@".\\UI\表情\" + shuiji.Next(1, 6) + ".png"); string[] word = File.ReadAllLines(@".\\yuyinku\4.txt", System.Text.Encoding.Default); label1.Text = word[shuiji.Next(0, word.Length)]; voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); voice.Speak(word[shuiji.Next(0, word.Length)]); keybd_event(0x71, 0, 0, 0);//按F2 if (Clipboard.GetText() != "") { Clipboard.Clear();//清空剪切板内容 } //pictureBox3.BackgroundImage = image; } } } } if (cyk.cymlzt == 2) { if (Clipboard.GetText() == "不创建" || Clipboard.GetText().Contains("不创建") || Clipboard.GetText().Contains("不")) { xyzt.open2 = 2; if (xyzt.open2 == 2) { xyzt.open2 = 0; cyk.cymlzt = 0; keybd_event(0x71, 0, 0, 0);//按F2 Random shuiji = new Random(); Image image = pictureBox3.BackgroundImage; pictureBox3.BackgroundImage = Image.FromFile(@".\\UI\表情\" + shuiji.Next(1, 6) + ".png"); string[] word = File.ReadAllLines(@".\\yuyinku\7.txt", System.Text.Encoding.Default); label1.Text = word[shuiji.Next(0, word.Length)]; voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); voice.Speak(label1.Text); keybd_event(0x71, 0, 0, 0);//按F2 //pictureBox3.BackgroundImage = image; } } else { if (Clipboard.GetText() == "创建" || Clipboard.GetText().Contains("创建") || Clipboard.GetText().Contains("好") || Clipboard.GetText().Contains("是"))//听到用户说创建 { xyzt.open2 = 1; if (xyzt.open2 == 1) { xyzt.open2 = 0; cyk.cymlzt = 0; System.Threading.Thread.Sleep(1000); if (Clipboard.GetText() != "") { Clipboard.Clear();//清空剪切板内容 } OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = "请选择文件"; fileDialog.Filter = "所有文件(*.*)|*.*"; if (fileDialog.ShowDialog() == DialogResult.OK) { string file = fileDialog.FileName; System.IO.Directory.CreateDirectory(@".\\"); DirectoryInfo dir = new DirectoryInfo(@".\\cyml"); dir.Create(); File.WriteAllText(@".//cyml/" + xydo.gettext + ".txt", file); string[] line = File.ReadAllLines(@".//cyml/mulu.txt", System.Text.Encoding.Default); string mulu = ""; foreach (string c in line) { mulu = c + "\r\n" + mulu; } mulu = mulu + xydo.gettext + "\r\n"; File.WriteAllText(@".//cyml/mulu.txt", mulu, System.Text.Encoding.Default); keybd_event(0x71, 0, 0, 0);//按F2 Random shuiji = new Random(); Image image = pictureBox3.BackgroundImage; pictureBox3.BackgroundImage = Image.FromFile(@".\\UI\表情\" + shuiji.Next(1, 6) + ".png"); string[] word = File.ReadAllLines(@".\\yuyinku\9.txt", System.Text.Encoding.Default); label1.Text = word[shuiji.Next(0, word.Length)]; voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); voice.Speak(word[shuiji.Next(0, word.Length)]); keybd_event(0x71, 0, 0, 0);//按F2 //pictureBox3.BackgroundImage = image; } else { keybd_event(0x71, 0, 0, 0);//按F2 Random shuiji = new Random(); Image image = pictureBox3.BackgroundImage; pictureBox3.BackgroundImage = Image.FromFile(@".\\UI\表情\" + shuiji.Next(1, 6) + ".png"); string[] word = File.ReadAllLines(@".\\yuyinku\7.txt", System.Text.Encoding.Default); label1.Text = word[shuiji.Next(0, word.Length)]; voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); voice.Speak(label1.Text); keybd_event(0x71, 0, 0, 0);//按F2 //pictureBox3.BackgroundImage = image; } } } } } }
//语音提示公共方法 public void Voice(string voice) { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice Voice = new SpVoice(); Voice.Rate = -2; Voice.Speak(voice, SpFlags); Voice.WaitUntilDone(5000); }
public void speak(string a) { if(mindInstance == null) return; try { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice speech = new SpVoice(); if (isSpeaking) { speech.Speak(a, SpFlags); } } catch { ; } }
public void Stop() { SpeakerSAPI5.Speak(null, (SpeechVoiceSpeakFlags)2); SpeakerSAPI5.Resume(); }
public void ScriptureAudio() { int scriptureReferenceVerseCount = -1; string exceptionMessage = null; string[][] scriptureReferenceArray = null; StringBuilder scriptureReferenceText = null; StringBuilder uriCrosswalkHtml = null; StringBuilder uriCrosswalkXml = null; StringBuilder[] scriptureReferenceBookChapterVersePrePostCondition = null; StringBuilder[] scriptureReferenceBookChapterVersePrePostSelect = null; StringBuilder scriptureReferenceBookChapterVersePrePostQuery = null; IDataReader iDataReader = null; ScriptureReferenceBookChapterVersePrePost[] scriptureReferenceBookChapterVersePrePost = null; ScriptureReference.ConfigurationXml ( filenameConfigurationXml, ref exceptionMessage, ref databaseConnectionString ); ScriptureReference.ScriptureReferenceParser ( new string[] { ScriptureReferenceSearch }, databaseConnectionString, ref exceptionMessage, ref scriptureReferenceBookChapterVersePrePost, ref scriptureReferenceArray, ref uriCrosswalkHtml, ref uriCrosswalkXml ); ScriptureReference.ScriptureReferenceQuery ( databaseConnectionString, ref exceptionMessage, ref scriptureReferenceBookChapterVersePrePost, ref iDataReader, ref scriptureReferenceVerseCount, ref scriptureReferenceText, ref scriptureReferenceBookChapterVersePrePostCondition, ref scriptureReferenceBookChapterVersePrePostSelect, ref scriptureReferenceBookChapterVersePrePostQuery ); if ( iDataReader != null ) { iDataReader.Close(); } DataSet dataSet = new DataSet(); UtilityDatabase.DatabaseQuery ( databaseConnectionString, ref exceptionMessage, ref dataSet, scriptureReferenceBookChapterVersePrePostQuery.ToString(), CommandType.Text ); StringBuilder sbScriptureReferenceVerseText = new StringBuilder(); foreach ( DataTable dataTable in dataSet.Tables ) { foreach ( DataRow dataRow in dataTable.Rows ) { sbScriptureReferenceVerseText.Append(dataRow["verseText"]); } } System.Console.WriteLine(sbScriptureReferenceVerseText); SpVoice spVoice = new SpVoice(); spVoice.Speak ( sbScriptureReferenceVerseText.ToString(), SpeechVoiceSpeakFlags.SVSFlagsAsync ); spVoice.WaitUntilDone(Timeout.Infinite); }
public void ThreadProcSafe() { MuteCheck p = new MuteCheck(); p.run(); while(true) { while(!p.mute_state) { //chờ bấm mute } //close all chrome first CloseAllChromeBrowsers(); Thread.Sleep(1000);//để kịp lên URL //swap channel index++; if (index >= channels.Length) index = 0; //webBrowser1.Navigate(channels[index]); System.Diagnostics.Process.Start(channels[index]); try { this.textBox1.Focus(); }catch(Exception ex) { } // Thread.Sleep(1000);//để kịp trả về unmute để nghe tên kênh //speake the channel name SpVoice voice = new SpVoice(); voice.Speak(channels_name[index]); //reverse state p.mute_state = false;//thay đổi trạng thái lại ban đầu } }
///<summary>SpVoiceSpeak</summary> public static void SpVoiceSpeak ( ref UtilitySpeechArgument utilitySpeechArgument, ref string exceptionMessage ) { object voice = null; object[] voiceArgv = null; SpeechVoiceSpeakFlags speechVoiceSpeakFlags = SpeechVoiceSpeakFlagsDefault; SpAudioFormatClass spAudioFormatClass = null; SpFileStream spFileStream = null; SpVoice spVoice = null; Type typeSAPISpVoice = null; try { spVoice = new SpVoice(); typeSAPISpVoice = Type.GetTypeFromProgID("SAPI.SpVoice"); voice = Activator.CreateInstance(typeSAPISpVoice); voiceArgv = new object[2]; voiceArgv[1] = 0; speechVoiceSpeakFlags = SpeechVoiceSpeakFlagsEnum(false, utilitySpeechArgument.xml); if (string.IsNullOrEmpty(utilitySpeechArgument.pathAudio) == false) { spAudioFormatClass = new SpAudioFormatClass(); spAudioFormatClass.Type = SpeechAudioFormatType.SAFTGSM610_11kHzMono; //Heavily compressed spFileStream = new SpFileStream(); spFileStream.Format = spAudioFormatClass; spFileStream.Open(utilitySpeechArgument.pathAudio, SpeechStreamFileMode.SSFMCreateForWrite, false); spVoice.AudioOutputStream = spFileStream; spVoice.Rate = -5; //Ranges from -10 to 10 } foreach (string text in utilitySpeechArgument.text) { spVoice.Speak(text, speechVoiceSpeakFlags); /* * voiceArgv[0] = text; * typeSAPISpVoice.InvokeMember("Speak", BindingFlags.InvokeMethod, null, voice, voiceArgv); */ } speechVoiceSpeakFlags = SpeechVoiceSpeakFlagsEnum(true, utilitySpeechArgument.xml); foreach (string pathSource in utilitySpeechArgument.pathSource) { if (string.IsNullOrEmpty(pathSource)) { continue; } if (File.Exists(pathSource) == false) { continue; } spVoice.Speak(pathSource, speechVoiceSpeakFlags); } //foreach( string pathSource in utilitySpeechArgument.pathSource ) } //try catch (Exception exception) { UtilityException.ExceptionLog(exception, exception.GetType().Name, ref exceptionMessage); } if (spFileStream != null) { spFileStream.Close(); } }//public static void SpVoiceSpeak()
private void processInputFromUser() { if (this.myBot.isAcceptingUserInput) { string rawInput = this.richTextBoxInput.Text; this.richTextBoxInput.Text = string.Empty; this.richTextBoxOutput.AppendText("You: " + rawInput + Environment.NewLine); Request myRequest = new Request(rawInput, this.myUser, this.myBot); Result myResult = this.myBot.Chat(myRequest); this.lastRequest = myRequest; this.lastResult = myResult; this.richTextBoxOutput.AppendText("Bot: " + myResult.Output + Environment.NewLine + Environment.NewLine); if (this.toolStripMenuItemSpeech.Checked) { SpVoice objSpeech = new SpVoice(); objSpeech.Speak(myResult.Output, SpeechVoiceSpeakFlags.SVSFlagsAsync); objSpeech.SynchronousSpeakTimeout = 20; objSpeech.Rate = 4; } } else { this.richTextBoxInput.Text = string.Empty; this.richTextBoxOutput.AppendText("Bot not accepting user input." + Environment.NewLine); } }
protected void Button2_Click(object sender, EventArgs e) { SpVoice voice = new SpVoice(); voice.Speak(lblbot.Text, SpeechVoiceSpeakFlags.SVSFDefault); }
private void button1_TextChanged(object sender, EventArgs e) { if (button1.Text == "Hello") { label1.Text = "Hello how can I help you?"; sp.Speak("Hello how can I help you?"); } if (button1.Text == "What is your name") { label1.Text = "My name is Assistant"; sp.Speak("My name is Busenin Assistant"); } if (button1.Text == "How are you") { label1.Text = "I am fine thank you. How are you?"; sp.Speak("I'm fine thank you. How are you?"); } if (button1.Text == "Thank you") { label1.Text = "I thank you. It was nice to talk to you."; sp.Speak("I thank you. It was nice to talk to you."); } if (button1.Text == "Black") { label1.Text = "Black"; sp.Speak("Here the black color is displayed"); BackColor = Color.Black; } if (button1.Text == "Yellow") { label1.Text = "Yellow"; sp.Speak("Here the yellow color is displayed"); BackColor = Color.Yellow; } if (button1.Text == "Red") { label1.Text = "Red"; sp.Speak("Here the red color is displayed"); BackColor = Color.Red; } if (button1.Text == "Blue") { label1.Text = "Blue"; sp.Speak("Here the blue color is displayed"); BackColor = Color.Blue; } if (button1.Text == "Germany") { sp.Speak("You can view everything about Germany here"); label1.Text = "You can view everything about Germany here"; webBrowser1.Navigate("https://www.google.com/search?q=Germany&safe=strict&bih=657&biw=1366&hl=en&sxsrf=ALeKk03kPz1FyloOBT4-PCZDfqxjVr5Zpg%3A1618710503909&ei=5497YL_yNtW73AOYv6voAQ&oq=Germany&gs_lcp=Cgdnd3Mtd2l6EANQ5Y0LWKCWC2C2pQtoAHACeACAAf8liAH_JZIBAzktMZgBAKABAaoBB2d3cy13aXrAAQE&sclient=gws-wiz&ved=0ahUKEwj_gdHE1obwAhXVHXcKHZjfCh0Q4dUDCA4&uact=5"); } if (button1.Text == "Turkey") { sp.Speak("You can view everything about Turkey here"); label1.Text = "You can view everything about Turkey here"; webBrowser1.Navigate("https://www.google.com/search?q=T%C3%BCrkiye&oq=T%C3%BCrkiye&aqs=chrome..69i57j0i271l3j69i60j69i61l2.3641j0j7&sourceid=chrome&ie=UTF-8"); } if (button1.Text == "Tokyo") { sp.Speak("You can view everything about Tokyo here"); label1.Text = "You can view everything about Tokyo here"; webBrowser1.Navigate("https://www.google.com/search?q=Tokyo&safe=strict&bih=657&biw=1366&hl=en&sxsrf=ALeKk01f4brLiXe3XOOGj32d0qgq4bX7cg%3A1618698953850&ei=yWJ7YNajM9WHwPAPqoiC4AQ&oq=Tokyo&gs_lcp=Cgdnd3Mtd2l6EAMyBwgjELADECcyBwgjELADECcyBwgjELADECcyBwgAEEcQsAMyBwgAEEcQsAMyBwgAEEcQsAMyBwgAEEcQsAMyBwgAEEcQsAMyBwgAEEcQsAMyBwgAEEcQsANQ3uO4BVjK-LgFYLj5uAVoAXACeACAAZMDiAGTA5IBAzQtMZgBAKABAaoBB2d3cy13aXrIAQrAAQE&sclient=gws-wiz&ved=0ahUKEwiWrJHBq4bwAhXVAxAIHSqEAEwQ4dUDCA4&uact=5"); } if (button1.Text == "University") { webBrowser1.Navigate("https://www.google.com/search?q=aksaray+%C3%BCniversitesi&safe=strict&bih=657&biw=1366&hl=en&sxsrf=ALeKk01xsYCrwvIx_gqtfsoZHv9_Ov6dJQ%3A1618711925014&ei=dZV7YK4Wt-Dv9Q-7oLjYBA&gs_ssp=eJzj4tLP1TdIt6xKjzcwYPQSTcwuTixKrFQ4vCcvsyy1qDizJLU4EwDRfAzw&oq=Aksaray+&gs_lcp=Cgdnd3Mtd2l6EAEYBjIGCCMQJxATMgQIIxAnMgQIIxAnMgUIABDLATIFCC4QywEyBQguEMsBMgUILhDLATIFCAAQywEyBQgAEMsBMgUIABDLAToFCAAQkQI6CwguEMcBEKMCEJECOgIIADoICC4QxwEQowI6AgguOgcIABCHAhAUULKcZFiFp2Rg1sFkaABwAngAgAHvA4gBgBOSAQkwLjMuMy4yLjGYAQCgAQGqAQdnd3Mtd2l6wAEB&sclient=gws-wiz"); sp.Speak("You can view everything about University Aksaray here"); } if (button1.Text == "Software") { webBrowser1.Navigate(" https://www.google.com/search?q=Yaz%C4%B1l%C4%B1m+nedir&safe=strict&bih=657&biw=1366&hl=en&sxsrf=ALeKk03MFigUxRm8aMkNsDmqTOUNvBpkSw%3A1618711280900&ei=8JJ7YLihNuePrgSdlZ7ABQ&oq=Yaz%C4%B1l%C4%B1m+nedir&gs_lcp=Cgdnd3Mtd2l6EAMyCggAEMsBEEYQ-QEyBQgAEMsBMgUIABDLATIFCAAQywEyBQgAEMsBMgUIABDLATIFCAAQywEyBQgAEMsBMgUIABDLATIFCAAQywE6BwgAEEcQsANQvDZYxkNgqkRoAXACeACAAcwCiAHrCZIBBzAuNC4xLjGYAQCgAQGqAQdnd3Mtd2l6yAEIwAEB&sclient=gws-wiz&ved=0ahUKEwi42ZC32YbwAhXnh4sKHZ2KB1gQ4dUDCA4&uact=5"); sp.Speak("You can view everything about Software here"); } if (button1.Text == "Google") { label1.Text = "Google opens"; System.Diagnostics.Process.Start("chrome.exe"); } if (button1.Text == "Capital") { label1.Text = "Turkey's capital, Ankara"; linkLabel1.Text = "Ankara View"; } if (button1.Text == "Paint") { System.Diagnostics.Process.Start("mspaint.exe"); } }
private void run_test() { /* * doPython(); * textbox.Text += "\n"; * StreamReader streamReader = new StreamReader(@"result.txt"); * textbox.Text += streamReader.ReadToEnd(); * streamReader.Close(); * textbox.ScrollToEnd(); * if (voice) { * //SpeechSynthesizer reader = new SpeechSynthesizer(); * } */ doPython(); textbox.Text += "\n ---------------------- \n"; StreamReader streamReader = new StreamReader(@"result.txt"); String tmp = streamReader.ReadToEnd(); streamReader.Close(); String speak_text = ""; SpVoice Voice = new SpVoice(); int errno = Convert.ToInt32(tmp); if (errno == 0) { if (voice) { Voice.Speak("Perfect Posture!"); } textbox.Text += "You have a perfect posture!\n"; } else { while (errno > 0) { if (errno >= 4) { if (voice) { Voice.Speak("Hunching back!"); } textbox.Text += "You are hunching your back!\n"; errno -= 4; } else if (errno >= 2) { if (voice) { Voice.Speak("Arms too close!"); } textbox.Text += "You arms are too close to your body!\n"; errno -= 2; } else if (errno >= 1) { if (voice) { Voice.Speak("Crossing legs!"); } textbox.Text += "You are crossing your legs!\n"; errno -= 1; } else { break; } } } textbox.ScrollToEnd(); }
void OnTriggerEnter(Collider objeto) { if (objeto.gameObject.tag == "Spawn") { Debug.Log("Toque Spawn"); Instantiate(papel, new Vector3(fondoCarrito.transform.position.x, objeto.gameObject.transform.position.y - 1.5f, fondoCarrito.transform.position.z), Quaternion.identity); objeto.gameObject.active = false; } if (objeto.gameObject.tag == "Papel") { Debug.Log("Toque Papel"); objeto.gameObject.transform.parent = jugador.transform; objeto.enabled = false; sonidoCarrito.PlayOneShot(sonidoPapel); objeto.gameObject.GetComponent <Rigidbody>().isKinematic = true; puntos++; puntuacion.GetComponent <Text>().text = puntos.ToString(); } if (puntos == 10) { voice.Speak("Usted ha ganado apa", SpeechVoiceSpeakFlags.SVSFlagsAsync); panelFinal.gameObject.SetActive(true); if (nextScene > PlayerPrefs.GetInt("levelAt")) { PlayerPrefs.SetInt("levelAt", nextScene); } string nivelActual; int tiempo5 = 30; int tiempo4 = 45; int tiempo2 = 60; int tiempo1 = 110; if (PlayerPrefs.GetInt("levelAt") == 3) { nivelActual = "nivel1"; tiempo5 = 30; tiempo4 = 45; tiempo2 = 60; tiempo1 = 110; } else if (PlayerPrefs.GetInt("levelAt") == 4) { tiempo5 = 40; tiempo4 = 55; tiempo2 = 70; tiempo1 = 120; nivelActual = "nivel2"; } else if (PlayerPrefs.GetInt("levelAt") == 5) { nivelActual = "nivel3"; tiempo5 = 45; tiempo4 = 60; tiempo2 = 75; tiempo1 = 125; } else { tiempo5 = 45; tiempo4 = 60; tiempo2 = 75; tiempo1 = 125; nivelActual = "nivel4"; } if (theTime <= tiempo5) { textoFinal.text = "Todo bien en casa?"; estrella1.active = true; estrella2.active = true; estrella3.active = true; estrella4.active = true; estrella5.active = true; PlayerPrefs.SetInt(nivelActual, 5); //Debug.Log("Perfecto"); } else if (theTime > tiempo5 & theTime <= tiempo4) { textoFinal.text = "Un buen trabajo"; estrella1.active = true; estrella2.active = true; estrella3.active = true; estrella4.active = true; PlayerPrefs.SetInt(nivelActual, 4); //Debug.Log("Perfecto"); } else if (theTime > tiempo4 & theTime <= tiempo2) { textoFinal.text = "Bien hecho"; estrella1.active = true; estrella2.active = true; estrella3.active = true; PlayerPrefs.SetInt(nivelActual, 3); } else if (theTime > tiempo2 & theTime <= tiempo1) { textoFinal.text = "Se puede mejorar"; estrella1.active = true; estrella2.active = true; PlayerPrefs.SetInt(nivelActual, 2); } else { textoFinal.text = "Ese papel se ve un poco viejo"; estrella1.active = true; PlayerPrefs.SetInt(nivelActual, 1); } scriptMov.active = false; } }
private void btnSpeech_Click(object sender, EventArgs e) { objSpeech.Speak(tbDoc.SelectedText, SpeechVoiceSpeakFlags.SVSFlagsAsync); }
public static void Speak(this iTunesApp itunes, string message) { var pasueMusic = itunes.PlayerState == ITPlayerState.ITPlayerStatePlaying; if (pasueMusic) { itunes.Pause(); } var voice = new SpVoice(); voice.Speak(message, SpeechVoiceSpeakFlags.SVSFDefault); if (pasueMusic) { itunes.Play(); } }
private static void MyCallbackFunction(object s1) { SpVoice objSpeech = new SpVoice(); objSpeech.Speak(s1.ToString(),SpeechVoiceSpeakFlags.SVSFlagsAsync); objSpeech.WaitUntilDone(-1); }
private void btnPronounce_Click(object sender, EventArgs e) { ShowAgent(); /* * AgentServer Srv = new AgentServer(); * if (Srv == null) * { * MessageBox.Show("ERROR: Agent Server couldn't be started!"); * * } * * IAgentEx SrvEx; * // The following cast does the QueryInterface to fetch IAgentEx interface from the IAgent interface, directly supported by the object * SrvEx = (IAgentEx)Srv; * * // First try to load the default character * int dwCharID = 0, dwReqID = 0; * try * { * // null is used where VT_EMPTY variant is expected by the COM object * String strAgentCharacterFile = null; * if (!strFileName.Equals(string.Empty)) * //Get the acs path * strAgentCharacterFile = strFileName; * else * { * MessageBox.Show("Select Style"); * return; * } * * if (cbbWord.Text.Equals(string.Empty)) * { * cbbWord.Text = "Please enter text in comboBox"; * } * SrvEx.Load(strAgentCharacterFile, out dwCharID, out dwReqID); * } * catch (Exception) * { * MessageBox.Show("Failed to load Agent character! Exception details:"); * } * * SrvEx.GetCharacterEx(dwCharID, out CharacterEx); */ //CharacterEx.SetLanguageID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US)); // Show the character. The first parameter tells Microsoft // Agent to show the character by playing an animation. // Make the character speak // Second parameter will be transferred to the COM object as NULL try { voice.Speak(cbbWord.Text, SpeechVoiceSpeakFlags.SVSFNLPSpeakPunc); //voice.Speak(cbbWord.Text, SpeechVoiceSpeakFlags.SVSFDefault); } catch (ExecutionEngineException) { MessageBox.Show("Failed to speak the word"); } CharacterEx.Speak(cbbWord.Text, null, out dwReqID); //CharacterEx.Wait(2000, out dwReqID); //CharacterEx.Listen(2000); }
private void SpeakUp() { try { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice Voice = new SpVoice(); int zeroBasedPinIndex = (int) projects[currentProjectName]; if (zeroBasedPinIndex == 0) { Voice.Speak("Someone broke the build for " + currentProjectName + "...", SpFlags); } // if (zeroBasedPinIndex == 1) // { // Voice.Speak("Build is green for " + currentProjectName + "...", SpFlags); // } // if (zeroBasedPinIndex == 2) // { // Voice.Speak("Building now for " + currentProjectName + "...", SpFlags); // } } catch(Exception error) { } }
private void MonitorSpeak() { SpVoice spv = new SpVoice(); if (spv == null) return; spv.Voice = spv.GetVoices(string.Empty, string.Empty).Item(cmbVoices.SelectedIndex); spv.Volume = 100; spv.Speak(sendString, SpeechLib.SpeechVoiceSpeakFlags.SVSFDefault); speak_Thread.Abort(); speak_Thread.Join(); speak_Thread = null; }
/// <summary> /// 语音提醒该车辆提交送货单 /// </summary>0:未提交 1:已提交 2:卸货中 3 卸货完成 /// <param name="voices"></param> public void Voice(string voices) { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice Voice = new SpVoice(); Voice.Rate = -5; Voice.Speak(voices, SpFlags); }
private void ThreadFinished(GThread th) { // cast GThread back to eduGRID_Thread eduGRID_Thread thread = (eduGRID_Thread)th; Append_Text("Bot: " + thread.Result); //chat_Display.AppendText("Bot: " + thread.Result); if (enableSpeechOutputToolStripMenuItem.Checked) { SpVoice objSpeech = new SpVoice(); objSpeech.Rate = 1; objSpeech.Speak(thread.Result, SpeechVoiceSpeakFlags.SVSFlagsAsync); //objSpeech.SynchronousSpeakTimeout = 20; } }
static void Main(string[] args) { SpVoice voice = new SpVoice(); foreach (SpObjectToken sp in voice.GetVoices()) { Console.WriteLine(sp.GetDescription()); } Stack <Interest> Dialogue = new Stack <Interest>(); Queue <Voice> talkers = new Queue <Voice>(); talkers.Enqueue(new Voice { Name = "Bao Dur", _root = ChatNode.FromString(File.ReadAllText("lines/lines_Bao-Dur.txt")) }); talkers.Enqueue(new Voice { Name = "Kreia", _root = ChatNode.FromString(File.ReadAllText("lines/lines_Kreia.txt")) }); talkers.Enqueue(new Voice { Name = "Exile", _root = ChatNode.FromString(File.ReadAllText("lines/lines_Exile.txt")) }); //talkers.Enqueue(new Voice { Name = "WHO", _root = ChatNode.FromString(File.ReadAllText("lines/lines_Who.txt")) }); Voice[] ppl = talkers.ToArray(); Random rand = new Random(); /* Add a point of Interest. These could be raised by finding items, doing quests, ect. */ Dialogue.Push(new Interest { Tags = new string[1] { "Greeting" } }); Module.GetString = (path) => { var arpath = path.ToLower().Split('/'); if (arpath[0] == "last") { var ln = Dialogue.Peek() as Line; if (ln != null) { return(ln.Author.GetString(arpath[1])); } } return(""); }; string[] current_topic = null; string response_name = null; Line response = null; while ( //TODO -- Find the Person with the highest level of interest. talkers.Any(talker => talker.HasInterest(current_topic = Dialogue.Peek().Tags, TOLERANCE) && !Dialogue.Contains(response = talker._root.VoiceInterest(current_topic)) && (response_name = talker.Name) != null && /*OH MY GOD YOU LAZY GIT*/ (response.Author = talker) != null ) ) { var strng = response.Output.Select(l => l.Resolve()).Aggregate((a, b) => a + b); Console.WriteLine(String.Format("{0}: {1}", response_name, strng)); voice.Speak(strng); Dialogue.Push(response); // Oh god, Stop me, please. // Just re-queues the talkers in random order // I really don't need a Queue anymore, I should just access an enumerable in a random fashion talkers.Enqueue(talkers.Dequeue()); /*talkers.Clear(); * var numbs = Enumerable.Range(0, ppl.Length).ToList(); * while (numbs.Any()) * { * int i = rand.Next(numbs.Count()); * int ind = numbs.ElementAt(i); * numbs.RemoveAt(i); * talkers.Enqueue(ppl[ind]); * }*/ } Console.ReadLine(); }
private void btn_Konus_Click(object sender, EventArgs e) { SpVoice sp = new SpVoice(); sp.Speak(txt_Girdi.Text); }
private void InvokeNonFirstMove() { if (!CheckWordAdjacent()) { MessageBox.Show("The word you put must be adjacent to existing word on the board", Application.ProductName); return; } if (!CheckWordPutCorrectly()) { MessageBox.Show("The word must be put either horizontally or vertically , and without spaces", Application.ProductName); return; } string incorrectWords = ""; foreach (String wordPut in wordsCombined) { if (!CheckWordFound(wordPut)) { incorrectWords += "'" + wordPut.ToLower() + "' " + "is not a word.\n"; } } // At least 1 incorrect word if (incorrectWords != "") { MessageBox.Show(incorrectWords, Application.ProductName); return; } // All words are correct - they are all found in dictionary wordsCombinationsPoints = ""; int totalWordsPoints = 0; // Speak the combined words if (isSpeakLegalWords) { SpVoice objSpeak = new SpVoice(); objSpeak.Voice = objSpeak.GetVoices("", "").Item(0); // Microsoft Anna for (int i = 0; i < wordsCombined.Count; i++) { objSpeak.Speak(wordsCombined[i].ToLower(), SpeechVoiceSpeakFlags.SVSFDefault); } } // Calculate score for all words together for (int i = 0; i < wordsCombined.Count; i++) { int wordPoints = GetWordPoints(wordsCombined[i], i); totalWordsPoints += wordPoints; score += wordPoints; } ToolTip toolTipWordPoints = new ToolTip(); toolTipWordPoints.OwnerDraw = true; // Anonymous event handler using lambda expression toolTipWordPoints.Draw += (sender, e) => { toolTipWordPoints.BackColor = Color.MediumSpringGreen; e.DrawBackground(); e.DrawText(TextFormatFlags.Left); }; wordsCombinationsPoints = totalWordsPoints + " points given.\n\n" + wordsCombinationsPoints; toolTipWordPoints.Show(wordsCombinationsPoints, lblBoardSquares[0], 563, 300, 6000); isMoveOK = true; }
private void Speech() { SpVoice Talk = new SpVoice(); Talk.Speak("Welcome Sir", 0); }
private void toolStripButton1_Click(object sender, EventArgs e) { label1.Text = "Firefox is opening"; sp.Speak("firefox is opening"); System.Diagnostics.Process.Start("firefox.exe"); }
private void button1_Click(object sender, EventArgs e) { SpVoice voice = new SpVoice();//SAPI 5.4,我的是win7系统自带的Microsoft Speech object library是5.4版本 voice.Voice = voice.GetVoices(string.Empty, string.Empty).Item(0); voice.Speak( richTextBox1.Text.Trim(), SpeechVoiceSpeakFlags.SVSFlagsAsync);//默认是女声说话 }
public void PlaySpeak(string text) { SpeechVoiceSpeakFlags flg = SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak; sv1.Speak(text, flg); }
public void speak(string a) { if(mindInstance == null) return; try { SpeechVoiceSpeakFlags SpFlags = SpeechVoiceSpeakFlags.SVSFlagsAsync; SpVoice speech = new SpVoice(); if (isSpeaking) { speech.Speak(a, SpFlags); } } catch { MessageBox.Show("Speech Engine error"); } }
private void GazeteHaber_KeyDown(object sender, KeyEventArgs e) { //klavyeden 'Y' tuşuna basıldığında seçilen başlığın içeriği okutuluyor. if (e.KeyCode == Keys.Y) { //timer2 durdularak içerik okutuluyor böylece haber başlıkları okuması duruyor. timer2.Stop(); //veritabanından bir önceki formda seçilen gazetenin rss datası çekiliyor. SqlCommand komut1 = new SqlCommand("select GazeteRSS from Gazeteler where GazeteAD='" + gztHaberLbl.Text + "'", bgl.baglanti()); SqlDataReader dr1 = komut1.ExecuteReader(); while (dr1.Read()) { //çekilen rss datası okutuluyor. XmlTextReader xmlicerikoku = new XmlTextReader(dr1["GazeteRSS"].ToString()); while (xmlicerikoku.Read()) { //çekilen rss datasındaki haber başlıkları çekiliyor if (xmlicerikoku.Name == "title") { //okunan başlık oluşturulan dizide 0.sütuna yazılıyor. dizi[titleindex, 0] = xmlicerikoku.ReadString(); //kullanıcının seçtiği başlık kontrol işlemi if (dizi[titleindex, 0] == lblOku.Text) { //seçilen başlık için tutma işlemi yapılıyor. secilenbaslikindex = titleindex; /* Test İşlemi. * MessageBox.Show("secilen:" + secilenbaslikindex); * MessageBox.Show("secilen:" + dizi[secilenbaslikindex, 0]); */ } //diziye sırayla ekleme yapması için 1 arttırılıyor. titleindex++; } //çekilen rss datasındaki haber içerikleri çekiliyor if (xmlicerikoku.Name == "description") { //okunan içerikler oluşturulan dizide 1.sütuna yazılıyor. dizi[descriptionindex, 1] = xmlicerikoku.ReadString(); //kullanıcının seçtiği başlık indexi bizim içerik indeximize eşit mi kontrol ediliyor. if (secilenbaslikindex == descriptionindex) { //seçili olan başlığı doğruya richTextBox'ımızın içine içeriğimizi yazdırıyoruz. richTextBox1.Text = dizi[descriptionindex, 1]; /*Test İşlemi. * MessageBox.Show("secilen:" + dizi[descriptionindex, 1]); * MessageBox.Show("secilen:" + descriptionindex); */ } //diziye sırayla ekleme yapılıyor. descriptionindex++; } } } //seçilen başlığın içeriği okutuluyor. SpVoice icerikokutma = new SpVoice(); icerikokutma.Speak(richTextBox1.Text); //içerik okutulduktan sonra kalan başlıktan devam etmesi sağlanıyor. i = kalanyer + 1; //tekrardan dizi değerleri 0'lanıyor. titleindex = 0; descriptionindex = 1; //timer2 başlatılarak kaldığı yerden haber başlıkları okutulmaya devam ediyor. timer2.Start(); //veri tabanı bağlantısı kapatılıyor. bgl.baglanti().Close(); } //Eğer Tüm Haberler Okunmuşsa Klavyeden 'T' tuşuna basıldığında tekrardan tüm haber başlıklarını okur. if (e.KeyCode == Keys.T) { //timer2'de haberler listboxa ekleniyor.O yüzden i değişkeni sıfırlayıp timerımızı başlatıyoruz. i = 0; timer2.Start(); } //Klavyeden 'B' tuşuna basıldığında form kapanıp bir önceki form açılmaktadır. if (e.KeyCode == Keys.B) { this.Close(); } }