コード例 #1
0
        public AIAudioResultCode ResumeAudio()
        {
            AIAudioResultCode code = AIAudioAPI.Resume();

            this.OnWriteLog("[AIAudioAPI_Resume] " + code);
            return(code);
        }
コード例 #2
0
        public AIAudioResultCode PauseAudio()
        {
            AIAudioResultCode code = AIAudioAPI.Suspend();

            this.OnWriteLog("[AIAudioAPI_Suspend] " + code);
            return(code);
        }
コード例 #3
0
        public AIAudioResultCode CloseAudio()
        {
            AIAudioResultCode code = AIAudioAPI.Close();

            this.OnWriteLog("[AIAudioAPI_Close] " + code);
            this._playing = false;
            return(code);
        }
コード例 #4
0
        public AIAudioResultCode StopAudio()
        {
            AIAudioResultCode code = AIAudioAPI.ClearData();

            this.OnWriteLog("[AIAudioAPI_ClearData] " + code);
            this._playing = false;
            return(code);
        }
コード例 #5
0
        public AIAudioResultCode SaveWave(string path, ref AIAudio_TWaveFormat format, short[] wave)
        {
            byte[] dst = new byte[wave.Length * 2];
            Buffer.BlockCopy(wave, 0, dst, 0, dst.Length);
            AIAudioResultCode code = AIAudioAPI.SaveWave(path, ref format, dst, (uint)dst.Length);

            this.OnWriteLog("[AIAudioAPI_SaveWave] " + code);
            return(code);
        }
コード例 #6
0
        public virtual AITalkResultCode SynthAsync(ref AITalk_TJobParam jobparam, string text)
        {
            int jobID;

            if (this._busy || this._playing)
            {
                return(AITalkResultCode.AITALKERR_TOO_MANY_JOBS);
            }
            this._busy    = true;
            this._playing = true;
            AITalk_TTtsParam param = new AITalk_TTtsParam();
            AITalkResultCode res   = this.GetParam(ref param);

            this.OnWriteLog("[AITalkAPI_GetParam] " + res);
            if (res != AITalkResultCode.AITALKERR_SUCCESS)
            {
                this._busy    = false;
                this._playing = false;
                return(res);
            }
            param.procTextBuf  = this._AITalkProcTextBuf;
            param.procRawBuf   = this._AITalkProcRawBuf;
            param.procEventTts = this._AITalkProcEventTTS;
            res = this.SetParam(ref param);
            this.OnWriteLog("[AITalkAPI_SetParam] " + res);
            if (res != AITalkResultCode.AITALKERR_SUCCESS)
            {
                this._busy    = false;
                this._playing = false;
                return(res);
            }
            this.OnWriteLog("[AIAuidoAPI_ClearData] " + AIAudioAPI.ClearData());
            res = AITalkAPI.TextToSpeech(out jobID, ref jobparam, text);
            this.OnWriteLog("[AITalkAPI_TextToSpeech] " + res);
            if (res != AITalkResultCode.AITALKERR_SUCCESS)
            {
                this._busy    = false;
                this._playing = false;
                return(res);
            }
            new Thread(delegate {
                AITalkStatusCode code;
                do
                {
                    Thread.Sleep(this.GetStatusInterval);
                    res = this.GetStatus(jobID, out code);
                }while ((this._playing && (res == AITalkResultCode.AITALKERR_SUCCESS)) && (code != AITalkStatusCode.AITALKSTAT_DONE));
                AITalkAPI.CloseSpeech(jobID, 0);
                this.OnWriteLog("[AITalkAPI_CloseSpeech] " + res);
                this._busy = false;
            })
            {
                IsBackground = true
            }.Start();
            return(res);
        }
コード例 #7
0
        public AIAudioResultCode OpenAudio(ref AIAudio_TConfig param)
        {
            AIAudio_TConfig config = param;

            config.procNotify = this._AIAudioProcNotify;
            AIAudioResultCode code = AIAudioAPI.Open(ref config);

            this.OnWriteLog("[AIAudioAPI_Open] " + code);
            return(code);
        }
コード例 #8
0
        public AIAudioResultCode PushEvent(ulong tick, IntPtr userData)
        {
            if (!this._playing)
            {
                return(AIAudioResultCode.AIAUDIOERR_NO_PLAYING);
            }
            AIAudioResultCode code = AIAudioAPI.PushEvent(tick, userData);

            this.OnWriteLog(string.Concat(new object[] { "[AIAudioAPI_PushEvent] ", code, " : ", tick }));
            if (code != AIAudioResultCode.AIAUDIOERR_SUCCESS)
            {
                this._playing = false;
            }
            return(code);
        }
コード例 #9
0
        public AIAudioResultCode PushData(short[] wave, int size, int stop)
        {
            if (!this._playing)
            {
                return(AIAudioResultCode.AIAUDIOERR_NO_PLAYING);
            }
            if (wave == null)
            {
                return(AIAudioResultCode.AIAUDIOERR_INVALID_ARGUMENT);
            }
            byte[] dst = new byte[size * 2];
            Buffer.BlockCopy(wave, 0, dst, 0, dst.Length);
            AIAudioResultCode code = AIAudioAPI.PushData(dst, (uint)dst.Length, stop);

            this.OnWriteLog(string.Concat(new object[] { "[AIAudioAPI_PushData] ", code, " : ", dst.Length }));
            if (code != AIAudioResultCode.AIAUDIOERR_SUCCESS)
            {
                this._playing = false;
            }
            return(code);
        }
コード例 #10
0
        public AITalkResultCode Do(AITalk.SynthMode synthMode, string text, AITalk.SynthOption synthOption)
        {
            AITalk_TJobParam param2;

            if (base._busy || base._playing)
            {
                return(AITalkResultCode.AITALKERR_TOO_MANY_JOBS);
            }
            this.SynthMode   = synthMode;
            this.SynthOption = synthOption;
            base._busy       = true;
            int jobID              = -1;
            AITalkResultCode code  = AITalkResultCode.AITALKERR_SUCCESS;
            AITalk_TTtsParam param = new AITalk_TTtsParam();

            code = base.GetParam(ref param);
            base.OnWriteLog("[AITalkAPI_GetParam] " + code);
            if (code != AITalkResultCode.AITALKERR_SUCCESS)
            {
                base._busy = false;
                return(code);
            }
            param.pauseBegin   = ((synthOption & AITalk.SynthOption.UseBeginPause) == AITalk.SynthOption.UseBeginPause) ? this._beginPause : 0;
            param.pauseTerm    = ((synthOption & AITalk.SynthOption.UseTermPause) == AITalk.SynthOption.UseTermPause) ? this._termPause : 0;
            param.procTextBuf  = base._AITalkProcTextBuf;
            param.procRawBuf   = base._AITalkProcRawBuf;
            param.procEventTts = base._AITalkProcEventTTS;
            code = base.SetParam(ref param);
            base.OnWriteLog("[AITalkAPI_SetParam] " + code);
            if (code != AITalkResultCode.AITALKERR_SUCCESS)
            {
                base._busy = false;
                return(code);
            }
            if ((this.SynthMode & AITalk.SynthMode.TextProcess) == AITalk.SynthMode.TextProcess)
            {
                this._jobInfo = new JobInfo(this.SynthMode, text, this.SynthOption, param.lenTextBufBytes, param.lenRawBufBytes);
            }
            else
            {
                this._jobInfo = new JobInfo(this.SynthMode, text, this.SynthOption, param.lenTextBufBytes, param.lenRawBufBytes);
                this._jobInfo.TextBlockList.Add(new JobInfo.TextBlock(0, text, text, "", 1f, 1f, 1f, 1f));
            }
            param2.userData = IntPtr.Zero;
            if (this.SynthMode == AITalk.SynthMode.TextProcess)
            {
                param2.modeInOut = AITalkJobInOut.AITALKIOMODE_PLAIN_TO_AIKANA;
            }
            else if ((this.SynthMode == AITalk.SynthMode.Synthesize) || (this.SynthMode == AITalk.SynthMode.KanaToSpeech))
            {
                param2.modeInOut = AITalkJobInOut.AITALKIOMODE_AIKANA_TO_WAVE;
            }
            else if ((this.SynthMode == AITalk.SynthMode.TextToWave) || (this.SynthMode == AITalk.SynthMode.TextToSpeech))
            {
                param2.modeInOut = AITalkJobInOut.AITALKIOMODE_PLAIN_TO_WAVE;
            }
            else
            {
                base._busy = false;
                return(code);
            }
            if ((this.SynthMode & AITalk.SynthMode.Play) == AITalk.SynthMode.Play)
            {
                AIAudioResultCode errorCode = AIAudioAPI.ClearData();
                base.OnWriteLog("[AIAuidoAPI_ClearData] " + errorCode);
                if ((errorCode != AIAudioResultCode.AIAUDIOERR_SUCCESS) && (errorCode != AIAudioResultCode.AIAUDIOERR_NO_PLAYING))
                {
                    this.InvokeUserEventHandler <ErrorEventArgs>(new EventInVoker <ErrorEventArgs>(this.OnErrorOccured), new ErrorEventArgs("ClearData", errorCode, ""));
                    base._busy = false;
                    return(code);
                }
                base._playing = true;
            }
            if ((this.SynthMode & AITalk.SynthMode.Synthesize) != AITalk.SynthMode.Synthesize)
            {
                code = AITalkAPI.TextToKana(out jobID, ref param2, this._jobInfo.SynthText);
                base.OnWriteLog(string.Concat(new object[] { "[AITalkAPI_TextToKana] ", code, " : ", jobID }));
            }
            else
            {
                code = AITalkAPI.TextToSpeech(out jobID, ref param2, this._jobInfo.SynthText);
                base.OnWriteLog(string.Concat(new object[] { "[AITalkAPI_TextToSpeech] ", code, " : ", jobID }));
            }
            if (code != AITalkResultCode.AITALKERR_SUCCESS)
            {
                base._playing = false;
                base._busy    = false;
                return(code);
            }
            this._jobInfo.JobID = jobID;
            new Thread(new ThreadStart(this.DoJob))
            {
                IsBackground = true
            }.Start();
            return(code);
        }