Ejemplo n.º 1
0
        public SpeechSynth()
        {
            _speechSynthData = new SpeechSynthData();
            UriBuilder uri = new UriBuilder(Assembly.GetExecutingAssembly().CodeBase);
            _speechSynthDir = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path)) + "\\VSTalker\\";
            _speechSynthConfigFilePath = _speechSynthDir + "default.vstalker";

            if (!Directory.Exists(_speechSynthDir))
                Directory.CreateDirectory(_speechSynthDir);

            if (File.Exists(_speechSynthConfigFilePath))
                LoadConfig(_speechSynthConfigFilePath);
            else
                _mustSave = true;
            foreach (InstalledVoice voice in _speechSynthesizer.GetInstalledVoices())
            {
                VoiceInfo info = voice.VoiceInfo;
                SpeechVoice speechVoice = GetSpeechVoiceByName(info.Name);
                if (speechVoice == null)
                {
                    speechVoice = new SpeechVoice(info.Name);
                    lock (_speechSynthData._speechVoiceList)
                    {
                        _speechSynthData._speechVoiceList.Add(speechVoice);
                    }
                    _mustSave = true;
                }
            }

            if (_mustSave)
                SaveConfig(_speechSynthConfigFilePath);
        }
Ejemplo n.º 2
0
        public void LoadConfig(Stream fromStream)
        {
            try
            {
                XmlSerializer SerializerObj = new XmlSerializer(typeof(SpeechSynthData));
                _speechSynthData = (SpeechSynthData)SerializerObj.Deserialize(fromStream);
            }
            catch (Exception)
            {

            }
            if (_speechSynthData._indexVoice >= 0 && _speechSynthData._indexVoice < _speechSynthData._speechVoiceList.Count)
                SetVoice(_speechSynthData._speechVoiceList[_speechSynthData._indexVoice]._voiceName);
        }
Ejemplo n.º 3
0
 public void LoadConfig(string filePath)
 {
     bool saveName = true;
     try
     {
         XmlSerializer SerializerObj = new XmlSerializer(typeof(SpeechSynthData));
         FileStream ReadFileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
         _speechSynthData = (SpeechSynthData)SerializerObj.Deserialize(ReadFileStream);
         ReadFileStream.Close();
     }
     catch (Exception)
     {
         saveName = false;
     }
     if(saveName)
     {
         _speechSynthConfigFilePath = filePath;
     }
 }