public void SelectVoiceByHints(VoiceGender gender, VoiceAge age, int voiceAlternate, CultureInfo culture) { Helpers.ThrowIfNull(culture, nameof(culture)); if (voiceAlternate < 0) { throw new ArgumentOutOfRangeException(nameof(voiceAlternate), SR.Get(SRID.PromptBuilderInvalidVariant)); } if (!VoiceInfo.ValidateGender(gender)) { throw new ArgumentException(SR.Get(SRID.EnumInvalid, "VoiceGender"), nameof(gender)); } if (!VoiceInfo.ValidateAge(age)) { throw new ArgumentException(SR.Get(SRID.EnumInvalid, "VoiceAge"), nameof(age)); } TTSVoice ttsVoice = VoiceSynthesizer.GetEngine(null, culture, gender, age, voiceAlternate, true); if (ttsVoice == null) { // No match - throw throw new InvalidOperationException(SR.Get(SRID.SynthesizerSetVoiceNoMatch)); } VoiceSynthesizer.Voice = ttsVoice; }
public void SpeakAsync(Prompt prompt) { Helpers.ThrowIfNull(prompt, nameof(prompt)); prompt.Synthesizer = this; VoiceSynthesizer.SpeakAsync(prompt); }
/// <summary> /// Resume the playback of all speech in this synthesizer. /// </summary> public void Resume() { if (_paused) { VoiceSynthesizer.Resume(); _paused = false; } }
private void SetOutputStream(Stream stream, SpeechAudioFormatInfo formatInfo, bool headerInfo, bool closeStreamOnExit) { SetOutputToNull(); _outputStream = stream; _closeStreamOnExit = closeStreamOnExit; // Need to serialize into a proper wav file before closing the stream VoiceSynthesizer.SetOutput(stream, formatInfo, headerInfo); }
/// <summary> /// Pause the playback of all speech in this synthesizer. /// </summary> public void Pause() { // Increment the Paused count if (!_paused) { VoiceSynthesizer.Pause(); _paused = true; } }
public ServerWindow() { InitializeComponent(); mServerVM = new ServerViewModel(); this.DataContext = mServerVM; this.Closing += mServerVM.OnWindow_Closing; synthesizer = new VoiceSynthesizer(); mServerVM.mServer.PropertyChanged += synthesizer.MServer_PropertyChanged; }
public ReadOnlyCollection <InstalledVoice> GetInstalledVoices(CultureInfo culture) { Helpers.ThrowIfNull(culture, nameof(culture)); if (culture.Equals(CultureInfo.InvariantCulture)) { throw new ArgumentException(SR.Get(SRID.InvariantCultureInfo), nameof(culture)); } return(VoiceSynthesizer.GetInstalledVoices(culture)); }
public void SelectVoice(string name) { Helpers.ThrowIfEmptyOrNull(name, nameof(name)); TTSVoice ttsVoice = VoiceSynthesizer.GetEngine(name, CultureInfo.CurrentUICulture, VoiceGender.NotSet, VoiceAge.NotSet, 1, true); if (ttsVoice == null || name != ttsVoice.VoiceInfo.Name) { // No match - throw throw new ArgumentException(SR.Get(SRID.SynthesizerSetVoiceNoMatch)); } VoiceSynthesizer.Voice = ttsVoice; }
public void Speak(Prompt prompt) { Helpers.ThrowIfNull(prompt, nameof(prompt)); // Avoid a dead lock if the synthesizer is Paused if (State == SynthesizerState.Paused) { throw new InvalidOperationException(SR.Get(SRID.SynthesizerSyncSpeakWhilePaused)); } prompt.Synthesizer = this; prompt._syncSpeak = true; VoiceSynthesizer.Speak(prompt); }
// The stream is disposed when the speech synthesizer is disposed public void SetOutputToNull() { // Close the existing stream if (_outputStream != Stream.Null) { VoiceSynthesizer.SetOutput(Stream.Null, null, true); } if (_outputStream != null) { if (_closeStreamOnExit) { _outputStream.Close(); } } _outputStream = Stream.Null; }
public static async void Run() { if (_wasRun) { return; } _wasRun = true; var builder = new ContainerBuilder(); var modules = new LayerModule[] { new CoreModule(), new ApplicationModule(), }; modules.ForEach(builder.RegisterModule); var container = builder.Build(); ServiceLocator.Init(container); modules.ForEach(m => m.OnPostContainerBuild(container)); //new AudioDeviceResource().StartCapture(); var s = new VoiceSynthesizer(); string[] texts = { "Привет мир", "как дела", "Hello world", "How are you?", "test", "give me that thing please", "thats why I here", "translation test", }; foreach (var text in texts) { await Task.Delay(500); s.Synthesize(text); } }
public void RemoveLexicon(Uri uri) { Helpers.ThrowIfNull(uri, nameof(uri)); VoiceSynthesizer.RemoveLexicon(uri); }
public void AddLexicon(Uri uri, string mediaType) { Helpers.ThrowIfNull(uri, nameof(uri)); VoiceSynthesizer.AddLexicon(uri, mediaType); }
public ReadOnlyCollection <InstalledVoice> GetInstalledVoices() { return(VoiceSynthesizer.GetInstalledVoices(null)); }
/// <summary> /// Cancel playback of all Prompts currently in the queue. /// </summary> public void SpeakAsyncCancelAll() { VoiceSynthesizer.Abort(); }
/// <summary> /// Cancel playback of all Prompts currently in the queue. /// </summary> public void SpeakAsyncCancel(Prompt prompt) { Helpers.ThrowIfNull(prompt, nameof(prompt)); VoiceSynthesizer.Abort(prompt); }