protected override int MyAITalkProcTextBuf(AITalkEventReasonCode reasonCode, int jobID, IntPtr userData) { uint size = 0; uint pos = 0; string kana = ""; if ((reasonCode == AITalkEventReasonCode.AITALKEVENT_TEXTBUF_FLUSH) || (reasonCode == AITalkEventReasonCode.AITALKEVENT_TEXTBUF_FULL)) { AITalkResultCode errorCode = AITalkAPI.GetKana(jobID, this._jobInfo.KanaBuffer, (uint)this._jobInfo.KanaBuffer.Capacity, out size, out pos); base.OnWriteLog(string.Concat(new object[] { "[AITalkAPI_GetKana] ", errorCode, " : ", size })); if (errorCode != AITalkResultCode.AITALKERR_SUCCESS) { this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("GetKana", errorCode, "")); } kana = this._jobInfo.KanaBuffer.ToString(); JobInfo.TextBlock textBlock = this._jobInfo.AddTextBlock((int)pos, kana); this._jobInfo.GrowTextProcessingProgress(textBlock); int textProcessingProgressPercentage = this._jobInfo.GetTextProcessingProgressPercentage(); TextProcessingEventArgs e = new TextProcessingEventArgs(textBlock.Pos, textBlock.Text, kana, textProcessingProgressPercentage); this.InvokeUserEventHandler <TextProcessingEventArgs>(new EventInVoker <TextProcessingEventArgs>(this.OnTextProcessingProgress), e); } else if (reasonCode == AITalkEventReasonCode.AITALKEVENT_TEXTBUF_CLOSE) { TextProcessingEventArgs args2 = new TextProcessingEventArgs(0, "", "", 100); this.InvokeUserEventHandler <TextProcessingEventArgs>(new EventInVoker <TextProcessingEventArgs>(this.OnTextProcessingComplete), args2); this._jobInfo.TextProcessingDone = true; base.OnWriteLog("[JobInfo] " + this._jobInfo.ToString()); } base.OnWriteLog(string.Concat(new object[] { "Callback [AITalkProcTextBuf] ", jobID, " : ", reasonCode.ToString(), " : ", (int)userData, " : ", kana })); return(0); }
protected override int MyAITalkProcEventTTS(AITalkEventReasonCode reasonCode, int jobID, ulong tick, string name, IntPtr userData) { base.OnWriteLog(string.Concat(new object[] { "Callback [AITalkProcEventTTS] ", jobID, " : ", reasonCode.ToString(), " : ", tick, " : ", name, " : ", (int)userData })); TTSEventArgs e = new TTSEventArgs(tick, name); if (reasonCode == AITalkEventReasonCode.AITALKEVENT_BOOKMARK) { int num; string text = this._jobInfo.ProgressBookMark(name, out num); if (text == null) { return(0); } if ((this.SynthMode & AITalk.SynthMode.Play) == AITalk.SynthMode.Play) { AudioEventParam item = new AudioEventParam(AudioEventCode.Bookmark, num, text, "", tick); this._jobInfo.AudioEventQueue.Enqueue(item); } this.InvokeUserEventHandler <TTSEventArgs>(new EventInVoker <TTSEventArgs>(this.OnTTSBookmark), e); } else if (reasonCode == AITalkEventReasonCode.AITALKEVENT_PH_LABEL) { if ((this.SynthMode & AITalk.SynthMode.Play) == AITalk.SynthMode.Play) { AudioEventParam param2 = new AudioEventParam(AudioEventCode.PhonemeLabel, 0, name, "", tick); this._jobInfo.AudioEventQueue.Enqueue(param2); } this.InvokeUserEventHandler <TTSEventArgs>(new EventInVoker <TTSEventArgs>(this.OnTTSPhonemeLabel), e); } return(0); }
protected virtual int MyAITalkProcRawBuf(AITalkEventReasonCode reasonCode, int jobID, ulong tick, IntPtr userData) { short[] wave = null; uint size = 0; if ((reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FLUSH) || (reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FULL)) { AITalkResultCode code = AITalkAPI.GetData(jobID, this._waveBuf, (uint)this._waveBuf.Length, out size); this.OnWriteLog(string.Concat(new object[] { "[AITalkAPI_GetData] ", code, " : ", size })); if ((code == AITalkResultCode.AITALKERR_SUCCESS) && (size > 0)) { wave = this._waveBuf; if (reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FLUSH) { this.PushEvent(tick, (IntPtr)2L); } this.PushData(wave, (int)size, 0); } } else if (reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_CLOSE) { this.PushEvent(tick, (IntPtr)3L); this.PushData(new short[0], 0, 1); } this.OnWriteLog(string.Concat(new object[] { "Callback [AITalkProcRawBuf] ", jobID, " : ", reasonCode.ToString(), " : ", tick, " : ", (int)userData, " : ", (wave != null) ? ((size * 2)).ToString() : "NODATA" })); return(0); }
protected virtual int MyAITalkProcEventTTS(AITalkEventReasonCode reasonCode, int jobID, ulong tick, string name, IntPtr userData) { this.OnWriteLog(string.Concat(new object[] { "Callback [AITalkProcEventTTS] ", jobID, " : ", reasonCode.ToString(), " : ", tick, " : ", name, " : ", (int)userData })); if (reasonCode == AITalkEventReasonCode.AITALKEVENT_BOOKMARK) { this.PushEvent(tick, (IntPtr)0L); } else if (reasonCode == AITalkEventReasonCode.AITALKEVENT_PH_LABEL) { this.PushEvent(tick, (IntPtr)1L); } return(0); }
protected virtual int MyAITalkProcTextBuf(AITalkEventReasonCode reasonCode, int jobID, IntPtr userData) { uint size = 0; uint pos = 0; string str = ""; if ((reasonCode == AITalkEventReasonCode.AITALKEVENT_TEXTBUF_FLUSH) || (reasonCode == AITalkEventReasonCode.AITALKEVENT_TEXTBUF_FULL)) { AITalkResultCode code = AITalkAPI.GetKana(jobID, this._kanaBuf, (uint)this._kanaBuf.Capacity, out size, out pos); this.OnWriteLog(string.Concat(new object[] { "[AITalkAPI_GetKana] ", code, " : ", size })); str = this._kanaBuf.ToString(); } this.OnWriteLog(string.Concat(new object[] { "Callback [AITalkProcTextBuf] ", jobID, " : ", reasonCode.ToString(), " : ", (int)userData, " : ", str })); return(0); }
protected override int MyAITalkProcRawBuf(AITalkEventReasonCode reasonCode, int jobID, ulong tick, IntPtr userData) { uint size = 0; short[] wave = null; if ((reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FLUSH) || (reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FULL)) { AITalkResultCode errorCode = AITalkAPI.GetData(jobID, this._jobInfo.WaveBuffer, (uint)this._jobInfo.WaveBuffer.Length, out size); base.OnWriteLog(string.Concat(new object[] { "[AITalkAPI_GetData] ", errorCode, " : ", size })); if (errorCode != AITalkResultCode.AITALKERR_SUCCESS) { this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("GetData", errorCode, "")); } if ((errorCode == AITalkResultCode.AITALKERR_SUCCESS) && (size > 0)) { wave = this._jobInfo.WaveBuffer; if (this._jobInfo.NextSentenceStartTick >= 0L) { JobInfo.TextBlock block = this._jobInfo.TextBlockList[this._jobInfo.CurrentIndex]; block.Tick = this._jobInfo.NextSentenceStartTick; if ((this.SynthMode & AITalk.SynthMode.Play) == AITalk.SynthMode.Play) { AIAudioResultCode code2 = base.PushEvent((ulong)block.Tick, new AudioEventParam(AudioEventCode.Sentence, block.Pos, block.Text, block.Kana, (ulong)block.Tick).ToIntPtr()); if ((code2 != AIAudioResultCode.AIAUDIOERR_SUCCESS) && (code2 != AIAudioResultCode.AIAUDIOERR_NO_PLAYING)) { this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("PushEvent_Progress", code2, "")); } } this._jobInfo.NextSentenceStartTick = -1L; } this.PushQueuedEvents(); if ((this.SynthMode & AITalk.SynthMode.Play) == AITalk.SynthMode.Play) { AIAudioResultCode code3 = base.PushData(wave, (int)size, 0); if ((code3 != AIAudioResultCode.AIAUDIOERR_SUCCESS) && (code3 != AIAudioResultCode.AIAUDIOERR_NO_PLAYING)) { this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("PushData_Progress", code3, "")); } } } if ((reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FLUSH) && ((this.SynthMode & AITalk.SynthMode.TextProcess) == AITalk.SynthMode.TextProcess)) { this._jobInfo.GrowSynthesizingProgress(this._jobInfo.TextBlockList[this._jobInfo.CurrentIndex]); this._jobInfo.NextSentenceStartTick = (long)tick; this._jobInfo.CurrentIndex++; } int progress = ((this.SynthMode & AITalk.SynthMode.TextProcess) == AITalk.SynthMode.TextProcess) ? this._jobInfo.GetSynthesizeingProgressPercentage() : 0; SynthesizingEventArgs e = new SynthesizingEventArgs(tick, wave, (int)size, reasonCode == AITalkEventReasonCode.AITALKEVENT_RAWBUF_FLUSH, progress); this.InvokeUserEventHandler <SynthesizingEventArgs>(new EventInVoker <SynthesizingEventArgs>(this.OnSynthesizingProgress), e); } else { if ((this.SynthMode & AITalk.SynthMode.Play) == AITalk.SynthMode.Play) { AIAudioResultCode code4 = base.PushEvent(tick, new AudioEventParam(AudioEventCode.Complete, 0, "", "", tick).ToIntPtr()); if (code4 == AIAudioResultCode.AIAUDIOERR_SUCCESS) { code4 = base.PushData(new short[1], 1, 1); if ((code4 != AIAudioResultCode.AIAUDIOERR_SUCCESS) && (code4 != AIAudioResultCode.AIAUDIOERR_NO_PLAYING)) { this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("PushData_Complete", code4, "")); } } else if (code4 != AIAudioResultCode.AIAUDIOERR_NO_PLAYING) { this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("PushEvent_Complete", code4, "")); } } SynthesizingEventArgs args2 = new SynthesizingEventArgs(tick, null, 0, false, 100); this.InvokeUserEventHandler <SynthesizingEventArgs>(new EventInVoker <SynthesizingEventArgs>(this.OnSynthesizingComplete), args2); this._jobInfo.SynthesizingDone = true; } base.OnWriteLog(string.Concat(new object[] { "Callback [AITalkProcRawBuf] ", jobID, " : ", reasonCode.ToString(), " : ", tick, " : ", (int)userData, " : ", (wave != null) ? ((size * 2)).ToString() : "NODATA" })); return(0); }