protected override void Open(WaveFormat format) { Buffers = new Queue <byte[]>(); bufPos = 0; SDATA s = new SDATA(); WAVEFORMATEX wfx = new WAVEFORMATEX(); wfx.cbSize = 0; wfx.nAvgBytesPerSec = (int)format.AverageBytesPerSecond; wfx.nBlockAlign = (short)format.BlockAlign; wfx.nChannels = (short)format.Channels; wfx.nSamplesPerSec = (int)format.SamplesPerSecond; wfx.wBitsPerSample = (short)format.BitsPerSample; wfx.wFormatTag = (short)format.FormatTag; s.AsWaveFormatEx = wfx; Sapi4Engine.miniLog("audio.WaveFormatSet"); audio.WaveFormatSet(s); Sapi4Engine.miniLog("audio.LevelGet"); int level; audio.LevelGet(out level); Sapi4Engine.miniLog(String.Format("level={0}", level)); // wfx = s.AsWaveFormatEx; Sapi4Engine.miniLog(String.Format("{0} Hz, {1} bit, {2} channels", wfx.nSamplesPerSec, wfx.wBitsPerSample, wfx.nChannels)); Sapi4Engine.miniLog("audio.Claim"); audio.Claim(); Sapi4Engine.miniLog("audio.Start"); audio.Start(); Sapi4Engine.miniLog(" opened successfully"); }
public void Select(Guid gModeID, out ITTSCentral ppiTTSCentral, IntPtr pIUnknownForAudio) { Sapi4Engine.miniLog(String.Format("EnumImpl.Select({0})", gModeID)); ppiTTSCentral = new Sapi4Engine(Array.Find <Sapi4Engine.ModeInfo>(modes, delegate(Sapi4Engine.ModeInfo mode) { return(mode.SapiMode.gModeID == gModeID); }), pIUnknownForAudio); }
public Sapi4AudioTarget(IAudioDest audioDest) { this.audioDest = audioDest; this.audio = audioDest as IAudio; Sapi4Engine.miniLog( String.Format( "audio target created, AudioDest is {0}, Audio is {1}", audioDest, audio)); }
void ITTSCentral.Inject(string pszTag) { try { miniLog("Inject"); } catch (Exception e) { Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.AudioResume() { try { miniLog("AudioResume"); } catch (Exception e) { Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.ModeGet(ref TTSMODEINFO pttsInfo) { try { miniLog("ModeGet"); pttsInfo = modeInfo.SapiMode; } catch (Exception e) { Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSEnum.Next(uint celt, IntPtr rgelt, IntPtr pceltFetched) { try { miniLog("Next"); myEnumImpl.Next(celt, rgelt, pceltFetched); } catch (Exception e) { Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.ToFileTime(ref ulong pqTimeStamp, out _FILETIME pFT) { try { miniLog("ToFileTime"); pFT.dwHighDateTime = pFT.dwLowDateTime = 0; } catch (Exception e) { pFT = new _FILETIME(); Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.PosnGet(out ulong pqwTimeStamp) { try { miniLog("PosnGet"); pqwTimeStamp = 0; } catch (Exception e) { pqwTimeStamp = 0; Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.Register(object pNotifyInterface, Guid IIDNotifyInterface, out uint pdwKey) { try { miniLog("Register " + IIDNotifyInterface + " " + pNotifyInterface.ToString()); notifySinks.Add(nextSinkKey, (ITTSNotifySink)pNotifyInterface); pdwKey = nextSinkKey++; } catch (Exception e) { pdwKey = 0; Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.Phoneme(VOICECHARSET eCharacterSet, uint dwFlags, SDATA dText, out SDATA pdPhoneme) { try { miniLog("Phoneme"); pdPhoneme = new SDATA(); pdPhoneme.dwSize = 0; } catch (Exception e) { pdPhoneme = new SDATA(); Sapi4Engine.miniLog(e + ": " + e.Message); } }
protected override void PlayBuffer(AudioBufferInfo buffer) { Sapi4Engine.miniLog("entering PlayBuffer"); Buffers.Enqueue(buffer.Data); int pos = 0; if (Buffers.Count < 1) { return; } else { Sapi4Engine.miniLog("at PlayBuffer"); int length = 0; bool destEof = false; do { audioDest.FreeSpace(ref length, ref destEof); Sapi4Engine.miniLog(String.Format("{0} bytes. eof: {1}", length, destEof)); if (!destEof) { int copied = 0; while ((copied < length) && (Buffers.Count > 0)) { byte[] buf = Buffers.Peek(); int toCopy = length - copied; int availCopy = Math.Min(buf.Length - bufPos, toCopy); IntPtr pmem = Marshal.AllocCoTaskMem(availCopy); Marshal.Copy(buf, bufPos, pmem, availCopy); Sapi4Engine.miniLog("before DataSet"); audioDest.DataSet(pmem, availCopy); Marshal.FreeCoTaskMem(pmem); Sapi4Engine.miniLog("after DataSet"); //System.Buffer.BlockCopy(buf, bufPos, buffer, pos, availCopy); copied += availCopy; bufPos += availCopy; pos += availCopy; if (bufPos >= buf.Length) { Buffers.Dequeue(); bufPos = 0; } } audioDest.FreeSpace(ref length, ref destEof); Sapi4Engine.miniLog(String.Format("second round {0} bytes. eof: {1}", length, destEof)); } System.Threading.Thread.Sleep(0); }while ((Buffers.Count > 0) && (destEof || (length == 0))); } Sapi4Engine.miniLog("leaving PlayBuffer"); }
void ITTSCentral.UnRegister(uint dwKey) { try { miniLog("UnRegister"); if (notifySinks.ContainsKey(dwKey)) { notifySinks.Remove(dwKey); } } catch (Exception e) { Sapi4Engine.miniLog(e + ": " + e.Message); } }
void ITTSCentral.TextData(VOICECHARSET eCharacterSet, uint dwFlags, SDATA dText, object pNotifyInterface, Guid IIDNotifyInterface) { try { miniLog("TextData " + dText.AsString); StringCharProducer scp = new StringCharProducer(dText.AsString); Tokenizer tokenizer = new Tokenizer(); Parser parser = new Parser(); Segmenter segmenter = new Segmenter(); Phonetizer phonetizer = new Phonetizer(); FujisakiProcessor fujisaki = new FujisakiProcessor(); MBROLATranslator translator = new MBROLATranslator(); MBROLASynthesizer synthesizer = new MBROLASynthesizer(); synthesizer.Voice = translator.Voice = modeInfo.Voice; tokenizer.Run(scp); parser.Run(tokenizer); segmenter.Run(parser); phonetizer.Run(segmenter); fujisaki.Run(phonetizer); translator.Run(fujisaki); synthesizer.Run(translator); /* DelegateConsumer<MBROLAElement> delegc = new DelegateConsumer<MBROLAElement>(); * delegc.ItemConsumed += delegate(MBROLAElement item) * { * miniLog("dummy sees: " + item.ToString()); * }; * delegc.Run(translator); * delegc.Join();*/ Sapi4AudioTarget target = new Sapi4AudioTarget(audioObject); target.Run(synthesizer); } catch (Exception e) { Sapi4Engine.miniLog(e + ": " + e.Message); } }
internal TTSEnumImpl(Sapi4Engine.ModeInfo[] modeArray) { Sapi4Engine.miniLog("EnumImpl created"); Sapi4Engine.miniLog("\tmodeArray=" + modeArray.ToString()); modes = modeArray; }
public void Reset() { Sapi4Engine.miniLog("EnumImpl.Reset"); modeIndex = 0; }
public void Skip(uint celt) { Sapi4Engine.miniLog("EnumImpl.Skip"); modeIndex += (int)celt; throw new Exception("ACK!@"); }