コード例 #1
0
        private void insertTextToSpeechToolStripMenuItem_Click(object sender, EventArgs e)
        {
            InsertTextToSpeech iword             = new InsertTextToSpeech();
            WaveFormat         currentWaveFormat = recorder.GetWaveFormat();

            iword.SetWaveFormat(currentWaveFormat);
            iword.ShowDialog();
            if (iword.DialogResult == DialogResult.OK)
            {
                MemoryStream partialWave = iword.GetWaveStream();
                if (partialWave != null)
                {
                    // insert actual audio bytes
                    recorder.InsertAudio(partialWave);

                    long position = recorder.getSelectionStart();
                    if (position < 0)
                    {
                        position = 0;
                    }
                    long adjust = (int)(partialWave.Length / (currentWaveFormat.BitsPerSample / 8));

                    // shift all simulator views past that insert over by that amount
                    int i;
                    //find the start of the insert
                    for (i = 0; (i < robotStates.Count) && (robotStates[i].position < position); i++)
                    {
                        ;
                    }
                    // add new states for each viseme
                    int           j;
                    List <Viseme> visemes = iword.GetVisemes();
                    for (j = 0; j < visemes.Count(); j++)
                    {
                        RobotState ss = conductor.CreateStateFromViseme(visemes[j].viseme);
                        ss.position = position + visemes[j].position;
                        robotStates.Insert(i++, ss);
                    }
                    while (i < robotStates.Count)
                    {
                        robotStates[i++].position += adjust;
                    }

                    conductor.SetStates(ref robotStates);
                }
            }
        }
コード例 #2
0
 void voice_Viseme(int StreamNumber, object StreamPosition, int Duration, SpeechVisemeType NextVisemeId, SpeechVisemeFeature Feature, SpeechVisemeType CurrentVisemeId)
 {
     conductor.SetState(conductor.CreateStateFromViseme((int)CurrentVisemeId));
 }