private void Init(string lang) { _callback = TtsCallback; _buffer = null; _bufferStream = null; if (lang != LanguageCode.None) { var langid = TextToSpeechStartLang(lang); if ((langid & TtsLangError) != 0) { switch (langid) { case TtsNotSupported: throw new FonixTalkException("This version of DECtalk does not support multiple languages."); case TtsNotAvailable: throw new FonixTalkException("The specified language was not found."); } } if (!TextToSpeechSelectLang(IntPtr.Zero, langid)) { throw new FonixTalkException("The specified language failed to load."); } } Check(TextToSpeechStartupEx(out _handle, 0xFFFFFFFF, 0, _callback, ref _handle)); Speak("[:phone on]"); // Enable singing by default }
private BufferRaiiHelper ReadyBuffer() { if (_buffer != null) { // Buffer was created by previous call to this method throw new InvalidOperationException("Buffer already exists."); } _buffer = new TtsBufferManaged(); unsafe { Check(TextToSpeechAddBuffer(_handle, _buffer.ValuePointer)); } return(new BufferRaiiHelper(this)); }
private void FreeBuffer() { _buffer.Dispose(); _buffer = null; }
private BufferRaiiHelper ReadyBuffer() { if (_buffer != null) { // Buffer was created by previous call to this method throw new InvalidOperationException("Buffer already exists."); } _buffer = new TtsBufferManaged(); unsafe { Check(TextToSpeechAddBuffer(_handle, _buffer.ValuePointer)); } return new BufferRaiiHelper(this); }
static unsafe extern MMRESULT TextToSpeechAddBuffer(IntPtr handle, TtsBufferManaged.TTS_BUFFER_T* buffer);