/// <summary> /// Called on availability of synthesized data. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="TranslationSynthesisEventArgs"/> instance containing the event data.</param> private void OnSynthesizingEventHandler(object sender, TranslationSynthesisEventArgs e) { var Clip = e.Result.GetAudio(); if (Clip.Length > 0) { Audios.Enqueue(Clip); lock (syncRoot) { isAudioNew = true; } } //var audio = e.Result.GetAudio(); //if (audio.Length > 0) //{ // using (var m = new MemoryStream(audio)) // { // SoundPlayer simpleSound = new SoundPlayer(m); // simpleSound.Play(); // } //} }
/// <summary> /// Called on availability of synthesized data. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="TranslationSynthesisEventArgs"/> instance containing the event data.</param> private void OnSynthesizingEventHandler(object sender, TranslationSynthesisEventArgs e) { var audio = e.Result.GetAudio(); if (audio.Length > 0) { using (var m = new MemoryStream(audio)) { SoundPlayer simpleSound = new SoundPlayer(m); simpleSound.Play(); } } }
public void Synthesizing(object sender, TranslationSynthesisEventArgs e) { byte[] audioBytes = e.Result.GetAudio(); if (audioBytes.Length == 0) { return; } var outputFilename = GetNextFilename(); if (outputFilename.EndsWith(".wav")) { using var fs = File.OpenWrite(outputFilename); fs.Write(audioBytes, 0, audioBytes.Length); } else { using var ms = new MemoryStream(audioBytes); ms.SaveWavToMp3File(outputFilename); } }
private void OnSynthesizing(object sender, TranslationSynthesisEventArgs e) { TranslationSynthesizing?.Invoke(sender, e); }