public void SpeakWithPromptBuilder() { var builder = new PromptBuilder(); builder.AppendText("This is something of a test"); builder.AppendAudio(@"E:\OneDrive\Music\mycomp\MusicalIntervals01\ExtractedPianoNotes\F#5.wav"); builder.AppendAudio(@"E:\OneDrive\Music\mycomp\MusicalIntervals01\ExtractedPianoNotes\E5.wav"); builder.AppendAudio(@"E:\OneDrive\Music\mycomp\MusicalIntervals01\ExtractedPianoNotes\PerfectFourth2.wav" ); builder.AppendAudio(@"E:\OneDrive\Music\mycomp\MusicalIntervals01\ExtractedPianoNotes\PerfectFourth3.wav"); _speechSynthesizer.Speak(builder); }
public void speakBuilder() { builder.StartParagraph(); builder.StartSentence(); foreach (Pictogram picto in taleManager.CurrentPage.Pictograms) { if (picto != null) { if (picto.Sound != "") { builder.AppendBookmark(picto.Index.ToString()); //builder.AppendBookmark(" "); //builder.StartStyle(styleAudio); builder.AppendAudio(picto.Sound); //builder.EndStyle(); } else { builder.AppendBookmark(picto.Index.ToString()); builder.StartStyle(styleText); builder.AppendText(picto.TextToRead); builder.EndStyle(); } } } builder.EndSentence(); builder.EndParagraph(); }
public static void Read() { try { CommonalityEntity.isvoic = false; PromptBuilder myprompt = new PromptBuilder(); //实例化对象构造一个语音定义 SpeechSynthesizer ss = new SpeechSynthesizer(); //实例化合成文字到语音 (TTS) 语音配合使用的类 ss.Volume = 100; //声音大小 ss.Rate = Convert.ToInt32(System.Configuration.ConfigurationManager.ConnectionStrings["Rate"].ToString()); //速度 ss.SelectVoice("VW Lily"); //设置语音包 string wavPath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Sounds\\ring.wav"; //要读的音频文件地址 if (!CommonalityEntity.ishujiao) { myprompt.AppendAudio(wavPath); //将音频文件追加到PromptBuilder } myprompt.AppendText(readTxt); //将文本追加到PromptBuilder for (int i = 0; i < readCount; i++) { ss.Speak(myprompt);//阅读 } CommonalityEntity.isvoic = true; ss.Dispose();//销毁 } catch { } }
// Use the speech synthesizer to play back the .wav file // that was created in the SpeechRecognized event handler. public static void TestAudio(object item) { string path = item as string; if (path != null && File.Exists(path)) { SpeechSynthesizer synthesizer = new SpeechSynthesizer(); PromptBuilder builder = new PromptBuilder(); builder.AppendText("Your recording is"); builder.AppendAudio(path); synthesizer.Speak(builder); completed = true; } }
public void SpeechSynthesizerToWavAndRepeat() { string wav = GetTestFilePath() + ".wav"; using (var synth = new SpeechSynthesizer()) { synth.SetOutputToWaveFile(wav); synth.Speak("hello"); } Assert.True(new FileInfo(wav).Length > 0); using var ms = new MemoryStream(); using (var synth = new SpeechSynthesizer()) { synth.SetOutputToWaveStream(ms); var builder = new PromptBuilder(); builder.AppendAudio(wav); synth.Speak(builder); Assert.True(ms.Position > 0); } }
public void SpeakAudio(string fileLocation) { var builder = new PromptBuilder(); builder.AppendAudio(fileLocation); _speechSynthesizer.Speak(builder); }
public static void Add_Audio(ref PromptBuilder builder, Uri audioFile, string alternateText) { builder.AppendAudio(audioFile, alternateText); }
public static void Add_Audio(ref PromptBuilder builder, Uri audioFile) { builder.AppendAudio(audioFile); }
public static void Add_Audio(ref PromptBuilder builder, string audioFilePath) { builder.AppendAudio(audioFilePath); }
public static void Add_wav(ref PromptBuilder builder, string filePath) { builder.AppendAudio(filePath); }
void IToneProvider.PlayAudio(string noteName) { var p = new PromptBuilder(); p.AppendAudio(noteName); var s = new SpeechSynthesizer(); s.Speak(p); }
/// <summary> /// Handler for MSG_QUERY /// </summary> /// <param name="message">The message received</param> protected async void MsgQuery(dynamic message) { var data = message["data"]; MycroftSpeaker speaker = speakers[data["targetSpeaker"]]; if (speaker.Status != "up") { await QueryFail(message["id"], "Target speaker is " + speaker.Status); } else { var text = data["text"]; PromptBuilder prompt = new PromptBuilder(new System.Globalization.CultureInfo("en-GB")); prompt.StartVoice(VoiceGender.Female, VoiceAge.Adult, 0); foreach (var phrase in text) { prompt.AppendText(phrase["phrase"]); prompt.AppendBreak(new TimeSpan((int)(phrase["delay"] * 10000000))); } prompt.EndVoice(); try { prompt.AppendAudio("lutz.wav"); } catch { } Thread t = new Thread(Listen); t.Start(new { speaker = speaker, prompt = prompt }); await Query("audioOutput", "stream_tts", new { ip = ipAddress, port = speaker.Port }, new string[] { speaker.InstanceId }); } }
public void PlayAudio(string noteName) { var p = new PromptBuilder(); p.AppendAudio(noteName); var synth = new SpeechSynthesizer(); synth.Speak(p); }
/// <summary> /// Play the musical interval a number of times (todo: improve that), followed by the description, /// e.g. "Minor second descending". /// The call to GetInterval does most of the hard work. /// </summary> /// <param name="interval"></param> /// <param name="delayInSeconds"></param> /// <param name="audioNotePrefix"></param> /// <param name="isAudio">true if the commentary is sourced from a wav file</param> public void PlayIntervalWithCommentary(List<int> interval, int delayInSeconds, string audioNotePrefix = "", bool isAudio = false) { PlayAndDelay(interval, delayInSeconds, isAudio); PlayAndDelay(interval, delayInSeconds, isAudio); var semitoneCount = interval[1] - interval[0]; var direction = NumberUtilities.GetSpokenDirection(NumberUtilities.GetDirection(interval)); var isDescending = NumberUtilities.IsDescending(interval); var spokenInterval = Intervals.GetInterval(semitoneCount, isAudio, audioNotePrefix, isDescending); if (!isAudio) { _synth.Speak( $"{spokenInterval}; {direction}"); } else { //audio... var builder = new PromptBuilder(); builder.AppendAudio(spokenInterval); _synth.Speak(builder); } Thread.Sleep(delayInSeconds * 1000); }