private void speak_progress(object sender, SpeakProgressEventArgs e) { plainText_tb.HideSelection = false; int textPosition = e.CharacterPosition; plainText_tb.Find(e.Text, textPosition, RichTextBoxFinds.WholeWord); }
/// <summary> /// Initializes a new instance of the <see cref="SpeakProgressEventData"/> class. /// </summary> /// <param name="e"> /// The event args from the System.Speech.Synthesis.SpeechSynthesizer.SpeakProgress event. /// </param> public SpeakProgressEventData(SpeakProgressEventArgs e) { this.AudioPosition = e.AudioPosition; this.CharacterPosition = e.CharacterPosition; this.CharacterCount = e.CharacterCount; this.Text = e.Text; }
void _synth_SpeakProgress(object sender, SpeakProgressEventArgs e) { richText.Select(e.CharacterPosition, e.CharacterCount); this.richText.ScrollToCaret(); richText.Focus(); System.Diagnostics.Debug.WriteLine(e.ToString()); }
/// <summary> /// Highlights words as they are spoken. /// </summary> /// <param name="sender">The object that sent this event.</param> /// <param name="e">A <c>SpeakProgressEventArgs</c> that contains the event data.</param> /// <seealso cref="https://msdn.microsoft.com/en-us/library/system.speech.synthesis.speechsynthesizer.speakprogress%28v=vs.110%29.aspx"/> /// <seealso cref="https://msdn.microsoft.com/en-us/library/system.speech.synthesis.speakprogresseventargs%28v=vs.110%29.aspx"/> private void SpeakProgress(object o, SpeakProgressEventArgs args) { // Determine the highlight starting location in the textbox from the pronounced string. int writtenStart = GetWrittenPositionFromSpoken(args.CharacterPosition); int writtenLength; // Are we in a pronunciation change? if (writtenToSpoken[writtenToSpokenIndex].PronunciationType == PronunciationTypeEnum.Spelling || writtenToSpoken[writtenToSpokenIndex].PronunciationType == PronunciationTypeEnum.Phoneme) { // We are in a pronunciation change. writtenStart = writtenToSpoken[writtenToSpokenIndex].WrittenPosition; writtenLength = writtenToSpoken[writtenToSpokenIndex].WrittenLength; } else if (writtenToSpoken[writtenToSpokenIndex].PronunciationType == PronunciationTypeEnum.None) { writtenLength = args.CharacterCount; } else // PronunciationTypeEnum.PhonemeOverhead { writtenLength = 0; } // Update the speech location. speechLocationInWritten = writtenStart; // If highlighting words as they are spoken. if (highlightSpokenWord) { // Select the current word. richTextBox1.SelectionStart = writtenStart + speakSelectionStart; richTextBox1.SelectionLength = writtenLength; } }
private static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e) { string word = e.Text; Console.WriteLine("Speaking: " + word); string wordToFind = word.ToLower().Trim(); wordToFind = wordToFind.Replace(".", ""); wordToFind = wordToFind.Replace(",", ""); wordToFind = wordToFind.Replace("?", ""); wordToFind = wordToFind.Replace("!", ""); wordToFind = wordToFind.Replace(":", ""); wordToFind = wordToFind.Replace(";", ""); wordToFind = wordToFind.Replace("'", ""); if (emotionalWords.ContainsKey(wordToFind)) { WordRecord record = emotionalWords[wordToFind]; Console.WriteLine("Found record: " + record.Word + "-" + record.Response); send("expression", record.Response); } if (progressStartSpeaking) { progressStartSpeaking = false; send("talking", "true"); } if (word.EndsWith(".") || word.EndsWith(",") || word.EndsWith("?") || word.EndsWith("!")) { progressStartSpeaking = true; send("talking", "false"); } }
private void SpeechProgress(object sender, SpeakProgressEventArgs e) { txtChapterText.HideSelection = false; int textposition = e.CharacterPosition; txtChapterText.Find(e.Text, textposition, RichTextBoxFinds.WholeWord); }
private void SpeakProgression(object sender, SpeakProgressEventArgs e) { //toolStripStatusLabel1.Text = $"Char {e.CharacterPosition + offset + 1}"; //Debug stuff. try { if (ReadingFromMainTextBox && highlightTextAsItsBeingSpokenToolStripMenuItem.Checked) { MainTextBox.SelectionStart = (int)(e.CharacterPosition + offset); MainTextBox.SelectionLength = e.CharacterCount; } } catch (Exception) { toolStripStatusLabel1.Text = $"Internal error highlighting text - Char {MainTextBox.SelectionStart}"; } try { toolStripProgressBar1.Maximum = (int)(lengthOfText); toolStripProgressBar1.Value = (int)(e.CharacterPosition + e.CharacterCount + offset); ToolbarIcon.Text = $"OutLoud Text Speaker - Speaking"; //TODO: Make this show the percentage } catch (Exception) { ToolbarIcon.Text = "OutLoud Text Speaker - Speaking"; toolStripProgressBar1.Value = 0; } }
void _reader_SpeakProgress(object sender, SpeakProgressEventArgs e) { if (_communicationDTO != null && _communicationDTO.CallbackSpeakProgress != null) { _communicationDTO.CallbackSpeakProgress(); } }
private void EhSpeakProgress(object sender, SpeakProgressEventArgs e) { if (_textOffsetInPrompt < 0) { _textOffsetInPrompt = e.CharacterPosition; } var(textPos, textEle) = FindMarker(e.CharacterPosition - _textOffsetInPrompt); if (null != _lastMarkedTextElement) { _lastMarkedTextElement.Background = _lastMarkedTextElementOriginalBackground; _lastMarkedTextElementOriginalBackground = null; } _lastMarkedTextElement = GetTextElementToMark(textEle); if (null != _lastMarkedTextElement) { _lastMarkedTextElementOriginalBackground = _lastMarkedTextElement.Background; _lastMarkedTextElement.Background = _spanBackBrushInPlay; } if (null != textEle) { _lastSpokenElement = textEle; textEle.BringIntoView(); } }
private void synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { string t = string.Empty; int c = _textToRead.Length; string token = string.Empty; int charCount = e.Text.Length; for (int i = _charPos; i < c; i++) { t = _textToRead.Substring(i, charCount); if (e.Text == t) { if (i - _charPos > 0 && _progress.Count > 0) { token = _textToRead.Substring(_charPos, i - _charPos); _progress[_progress.Count - 1].Text += token; } //t = _textToRead.Substring(i, e.CharacterCount); _charPos = i + charCount; break; } } //Fix negative timespan issue TimeSpan audioPos = e.AudioPosition; if (e.AudioPosition.Ticks < 0) { if (_lastPositiveTime == null) { _lastPositiveTime = _progress[_progress.Count - 1].AudioPosition; } audioPos = new TimeSpan(2 * _lastPositiveTime.Value.Ticks + e.AudioPosition.Ticks); } var prog = new SpeakProgress() { AudioPosition = audioPos, CharacterCount = charCount, CharacterPosition = e.CharacterPosition, Text = t }; _progress.Add(prog); if (100 * _charPos / c > _percentage) { _percentage = 100 * _charPos / c; Console.Write(string.Format("\r{0:d3}%", _percentage)); } //s = s + e.Text + Environment.NewLine; //Console.WriteLine("SpeakProgress: AudioPosition=" + e.AudioPosition + ",\tCharacterPosition=" + e.CharacterPosition + ",\tCharacterCount=" + e.CharacterCount + ",\tText=" + e.Text); //_s = _s + "SpeakProgress: AudioPosition=" + e.AudioPosition + ",\tCharacterPosition=" + e.CharacterPosition + ",\tCharacterCount=" + e.CharacterCount + ",\tText=" + e.Text + Environment.NewLine; }
private void OnSpeakProgress(object sender, SpeakProgressEventArgs args) { // With Cortana, this event can be fired for two different words // simultaneously while the first is still being read. richText.Select(args.CharacterPosition + lastSelectionOffset, args.CharacterCount); if (enableTaskbar) { taskbar.SetProgressValue(args.CharacterPosition + args.CharacterCount, textLength); } }
private void reader_SpeakProgress(object sender, SpeakProgressEventArgs e) { wordCount++; if (shouldUnderlineWord) { StringToXamlConverter.currentWordIndex = wordCount; readingTextView.Text = sb.ToString(); //readingTextView.NotifyPropertyChanged(); //UpdateTextBlock(); } }
protected virtual void OnProgressReached(SpeakProgressEventArgs e) { EventHandler <System.Speech.Synthesis.SpeakProgressEventArgs> handler = SpeakProgress; if (handler != null) { //Progress: 0 % pause = false; SynthesizerState state = speaker.State; //speaker_SpeakProgress(null, e); } }
private void Reader_SpeakProgress(object sender, SpeakProgressEventArgs e) { double p = Math.Round(((e.CharacterPosition * 1.0d) / (SelectedBook.CurrentReadedChapter.ChapterConent.Length * 1.0d)) * 100, 1); Progress = (int)p; if (p >= 99) { Console.WriteLine(e.CharacterPosition + "," + SelectedBook.CurrentReadedChapter.ChapterConent.Length); Console.WriteLine("自动开始下一章" + SelectedBook.CurrentReadedChapter.NextChapter?.Name); NextCmd.Execute(null); progress = 0; } }
protected void speechSynthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { try { //Trace.Write("speechSynthesizer_SpeakProgress\n"); //if (speechRecognitionEngine != null) // speechRecognitionEngine.RecognizeAsyncStop(); } catch (Exception ex) { Trace.Write(ex.ToString()); } }
public async Task <VoiceData> GenerateVoiceAsWavFile(CancellationToken token) { Trace.WriteLine("Starting Generation of Wav using SAPI"); var audioFormat = new SpeechAudioFormatInfo(SamplesPerSecond, AudioBitsPerSample.Sixteen, AudioChannel.Stereo); using (var speechSynthesizer = new SpeechSynthesizer()) { SelectVoice(speechSynthesizer); using (MemoryStream streamAudio = new MemoryStream()) { SpeakProgressEventArgs progressEvents = null; speechSynthesizer.SetOutputToWaveStream(streamAudio); speechSynthesizer.SpeakProgress += (sender, e) => { progressEvents = e; }; TaskCompletionSource <bool> finished = new TaskCompletionSource <bool>(token); speechSynthesizer.SpeakCompleted += (object sender, SpeakCompletedEventArgs e) => { if (e.Error != null) { finished.TrySetException(e.Error); } else if (e.Cancelled) { finished.TrySetCanceled(); } else { finished.TrySetResult(true); } }; token.Register(() => speechSynthesizer.SpeakAsyncCancelAll()); try { var prompt = speechSynthesizer.SpeakAsync(promptBuilder); await finished.Task.ConfigureAwait(false); } catch (Exception ex) { throw new VoiceGenerationException(Invariant($"Voice Generation Failed with {ex.GetFullMessage()}")); } speechSynthesizer.SetOutputToNull(); Trace.WriteLine("Finished Generation of Wav using SAPI"); return(new VoiceData(streamAudio.ToArray(), "wav", progressEvents != null ? (TimeSpan?)progressEvents.AudioPosition : null)); } } }
private void synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { lock (playLock) { if (play) { textDisplay.SelectText(e.CharacterPosition, e.CharacterCount); } else { synthesizer.Pause(); } } }
private void Synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { var promptTxt = e.Prompt.GetText(); var txt = promptTxt.Substring(e.CharacterPosition, e.CharacterCount + 1); currentlySpoken.Append(txt); statusText.Text = currentlySpoken.ToString(); var last = txt.Last(); if (last == '!' || last == '.' || last == ';' || last == ':') { currentlySpoken.Clear(); } }
private void Speaker_SpeakProgress(object sender, SpeakProgressEventArgs e) { txtData.Focus(); lblStatus.ForeColor = Color.SkyBlue; if (rdbtnFile.Checked) { lblStatus.Text = "Status: Writing in Progress! Please Wait"; } else { lblStatus.Text = "Status: Reading in Progress! Please Wait"; } DisableControls(); txtData.Select(e.CharacterPosition, e.CharacterCount); }
private void SpeakProgresser(object sender, SpeakProgressEventArgs e) { //для пропуска слов что не читаються к примеру просто различних знаков припинания while (!regexReadWord.IsMatch(wordsOriginal[indexOriginalCurentWord])) { CalculatedIndexersToSelentionText(); } SelectTextOrifginal(); SelectTextTranslate(); SelectTextLiteralTranslate(); AllReadersPause(); CalculatedIndexersToSelentionText(); AllReadersResume(); }
private void speech_synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { // Add the current word to our list last_words.Add(e.Text); while (last_words.Count > 10) { last_words.RemoveAt(0); last_words.RemoveAt(0); last_words.RemoveAt(0); last_words.RemoveAt(0); last_words.RemoveAt(0); } string textwindow = ArrayFormatter.ListElements(last_words, " "); StatusManager.Instance.UpdateStatus("ReadOutAloud", textwindow, e.CharacterPosition, current_prompt_length); }
protected void UpdateSynthesisProgress(object sender, SpeakProgressEventArgs e) { if (pbSpeaking == null) { return; } pbSpeaking.Value = e.CharacterPosition; #if debug Console.WriteLine("Speak progress: {0} AudioPosition: {1} Text: {2}", e.CharacterPosition, e.AudioPosition, e.Text); #endif if (string.IsNullOrWhiteSpace(rtbPage.Text)) { return; } rtbPage.Find(e.Text, synthesizablePDF.ReadingStartPosition + e.CharacterPosition, RichTextBoxFinds.WholeWord); rtbPage.Focus(); }
void synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { //phoneme = ""; if (saveData) { // double rate = 1 + synthesisSpeakRate * 0.1; if (rate > 1) { rate = 1; } totalSentenceDuration = e.AudioPosition.TotalMilliseconds * (rate); prompt += e.Text + " "; string data = "time::" + (startTime + totalSentenceDuration) + "|confidence::0.99|textResult::" + prompt.Trim() + "|isHypothesis::True|grammarName::|ruleName::index_" + startIndex + "|duration::-1|wavePath::\n"; writeToFile(data); } }
// this will be called each time a new word is begining to be read by the SpeechSynthesizer void _synth_SpeakProgress(object sender, SpeakProgressEventArgs e) { TextPointer newPos; // Get a TextPointer for the start of the word if (countToLastPoint < e.CharacterPosition) { // use he lsatPoint if posible newPos = GetPositionAtTextOffset(lastPoint, e.CharacterPosition - countToLastPoint); } else { // otherwise start from the start newPos = GetPositionAtTextOffset(startedReading, e.CharacterPosition); } if (newPos == null) { ReadText = null; return; } // And get the end var end = GetPositionAtTextOffset(newPos, e.Text.Length); if (end == null) { end = newPos; } else { // update lastpoint lastPoint = end; countToLastPoint = e.CharacterPosition + e.Text.Length; } // Create a new TextRange that indicates the read word // a new TextRange is created to make sure protychanged is called // and noone else use the old textrange. ReadText = new TextRange(newPos, end); }
protected virtual void OnSAPISpeakingSentence(object sender, SpeakProgressEventArgs eventArgs) { IsSpeaking = true; int index = eventArgs.CharacterPosition + eventArgs.CharacterCount; if (index > 0) { index = index - 1; } if (index > SpeakingSentence.Length) { index = SpeakingSentence.Length; } string SpokenString = SpeakingSentence.Substring(0, index); SpokenSentence spokenSentence = new SpokenSentence(); spokenSentence.Sentence = SpokenString; OnSpokenSentenceEvent(spokenSentence); }
void synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { //Clients.All.addNewMessageToPage("", e.CharacterPosition); }
/// <summary> /// Raises the SpeakProgress event /// </summary> /// <param name="e"></param> protected void OnSpeakProgress(SpeakProgressEventArgs e) { double percentage = (double)SpokenString.Length / (double)e.CharacterCount; base.OnSpeakProgress(percentage); }
private void synth_SpeakProgress(object sender, SpeakProgressEventArgs e) { textboxWordDisplay.Text = e.Text; if (lastWord == e.Text) { return; } int selLength = e.Text.Length; offset = textboxToSpeak.Text.IndexOf(e.Text, selStart, StringComparison.InvariantCultureIgnoreCase); if (offset >= 0) { textboxToSpeak.Select(offset, selLength); textboxToSpeak.ScrollToCaret(); selStart = offset + selLength; lastWord = e.Text; } }
protected void synt_SpeakProgress(object sender, SpeakProgressEventArgs e) { textBox1.Select(e.CharacterPosition, e.CharacterCount); }
protected virtual void OnSpeakProgress(object sender, SpeakProgressEventArgs e) { var handler = this.SpeakProgress; if (handler != null) handler(this, e); }
private void Reader_SpeakProgress(object sender, SpeakProgressEventArgs e) { this.textBox1.Range.ClearStyle(Highlightstyle); this.textBox1.Range.SetStyle(Highlightstyle, e.Text, System.Text.RegularExpressions.RegexOptions.IgnoreCase); }
private static void synth_SpeakProgress(object sender, SpeakProgressEventArgs e, BackgroundWorker worker, int charTotal) { worker.ReportProgress((Convert.ToInt16((int)(((long)e.CharacterPosition*100)/charTotal)))/2); // divide by two so only 50% will be used up }
private void OnSpeakProgress(object sender, SpeakProgressEventArgs e) { var time = this.pipeline.GetCurrentTime(); this.SpeakProgress.Post(new SpeakProgressEventData(e), time); }
private void Speech_SpeakProgress(object sender, SpeakProgressEventArgs e) { Console.WriteLine("teste"); }
private void SpeechSynthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { this.SpeakingTextIndex += this.SpeakingText.Length; this.SpeakingText = e.Text; this.SpeakingTextIndex = this.Text.IndexOf(this.SpeakingText, this.SpeakingTextIndex); }
private void synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { this.InjectScript("$('#action-buttons-progress').html('<b>" + e.Text + "</b>')"); Console.WriteLine("SpeakProgress: AudioPosition=" + e.AudioPosition + ",\tCharacterPosition=" + e.CharacterPosition + ",\tCharacterCount=" + e.CharacterCount + ",\tText=" + e.Text); }
void speechSynth_SpeakProgress(object sender, SpeakProgressEventArgs e) { OnSpeakProgress(e); }
void synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { pictureBox1.Image = bmps[ind % bmps.Length]; ind++; }
void _synthesizer_SpeakProgress(object sender, SpeakProgressEventArgs e) { textBox1.Select(e.CharacterPosition, e.CharacterCount); }