Beispiel #1
0
        /// <summary>
        /// Opens an audio-file w/out processing it.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void click_Open(object sender, EventArgs e)
        {
#if DEBUG
            logfile.Log();
            logfile.Log("click_Open()");
#endif
            using (var ofd = new OpenFileDialog())
            {
                ofd.Title  = "Select a WAV or MP3 Audio file";
                ofd.Filter = "Audio files (*.wav;*.mp3)|*.wav;*.mp3|"                 // TODO: handle BMU files
                             + "Wave files (*.wav)|*.wav|"
                             + "Mp3 files (*.mp3)|*.mp3|"
                             + "All files (*.*)|*.*";

                if (Directory.Exists(_dirOpen))
                {
                    ofd.InitialDirectory = _dirOpen;
                }
                else
                {
                    ofd.InitialDirectory = Application.StartupPath;
                }

                // else let .NET handle it.

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    _dirOpen = Path.GetDirectoryName(ofd.FileName);

                    tb_wavefile.Text = _pfe = ofd.FileName;
#if DEBUG
                    logfile.Log(". _pfe= " + _pfe);
#endif
                    Clear();

                    co_headtype.Enabled      =
                        bu_createfxe.Enabled = false;

                    tb_text.Text = LoadTypedTextFile();

                    Filelabel = Utility.GetFilelabel(_pfe);                     // NOTE: that will be written into the FXE-file output.

                    string pfe = _pfe.Substring(0, _pfe.Length - 3) + FxeGeneratorF.EXT_FXE;
                    if (FxeReader.ReadFile(pfe, _fxedata))
                    {
                        PopulateDataGrid();
                    }

                    _sapi.Wavefile = AudioConverter.deterwave(_pfe);
#if DEBUG
                    logfile.Log(". _sapi.Wavefile= " + _sapi.Wavefile);
#endif
                    bu_generate.Enabled =
                        bu_play.Enabled = (_sapi.Wavefile != String.Empty);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// cTor.
        /// </summary>
        /// <param name="pfe">blank string if '!isConsole'</param>
        internal SapiLipsync(string pfe = "")
        {
            That = this;
#if DEBUG
            logfile.Log();
            logfile.Log("SapiLipsync() cTor pfe= " + pfe);

            logfile.Log(". create (SpVoice)_voice");
#endif
            _voice = new SpVoice();
#if DEBUG
            logfile.Log(". (SpVoice)_voice CREATED");
#endif
            _voice.Volume     = 0;
            _voice.Rate       = 10;
            _voice.Phoneme   += tts_Phoneme;
            _voice.EndStream += tts_EndStream;

            /*
             * https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee125220%28v%3dvs.85%29
             * enum SpeechVoiceEvents
             * SVEStartInputStream = 2
             * SVEEndInputStream   = 4
             * SVEVoiceChange      = 8
             * SVEBookmark         = 16
             * SVEWordBoundary     = 32
             * SVEPhoneme          = 64
             * SVESentenceBoundary = 128 <-
             * SVEViseme           = 256 <--
             * SVEAudioLevel       = 512
             * SVEPrivate          = 32768
             * SVEAllEvents        = 33790
             */
            _voice.EventInterests = (SpeechVoiceEvents)(int)SpeechVoiceEvents.SVEPhoneme
                                    + (int)SpeechVoiceEvents.SVEEndInputStream;
#if DEBUG
            logfile.Log(". _voice.EventInterests= " + _voice.EventInterests);
#endif

#if DEBUG
            logfile.Log(". create (SpPhoneConverter)_phoneConverter");
#endif
            _phoneConverter = new SpPhoneConverter();
#if DEBUG
            logfile.Log(". (SpPhoneConverter)_phoneConverter CREATED");
//			PrintPhons(1036); // test fr-FR
#endif

            if (FxeGeneratorF.isConsole)
            {
                _phoneConverter.LanguageId = 1033;                 // EnglishUS (default) // TODO: <--
                Wavefile = AudioConverter.deterwave(pfe);
#if DEBUG
                logfile.Log(". Wavefile= " + Wavefile);
#endif
            }
        }