private bool SpeakToFile(string[] splitData, string filePath)
        {
            if (!tmpVoicesAllocations.ContainsKey(splitData[1]))
            {
                // get random voice from selected voices by gender
                Voice[] voices    = GetSelectedVoices();
                Gender  gender    = (splitData[0] == "f") ? Gender.Female : Gender.Male;                      // get gender
                Voice[] genVoices = Array.FindAll(voices, delegate(Voice v) { return(v.Gender == gender); }); // find voices by gender
                genVoices = genVoices.Length == 0 ? voices : genVoices;                                       // if no voice for gender selected select ay
                tmpVoicesAllocations.Add(splitData[1], genVoices[new Random().Next(genVoices.Length)]);       // allocate voice to npcid
            }

            Voice voice = tmpVoicesAllocations[splitData[1]];

            string err = null;

            switch (voice.Module)
            {
            case Module.Windows:
                err = WindowsTTS.Speak(splitData[2], voice, filePath);
                break;

            case Module.Azure:
                err = AzureTTS.Speak(splitData[2], voice, filePath, config.AzureAPI);
                break;

            case Module.Google:
                err = GoogleTTS.Speak(splitData[2], voice, filePath);
                break;

            case Module.AWS:
                err = AwsTTS.Speak(splitData[2], voice, filePath, config.AwsAPI);
                break;
            }

            if (err != null)
            {
                OnError(err);
                return(false);
            }

            OnSpeechPrepare(voice);

            return(true);
        }
        private void VoiceTestSpeak(string txt, QuestToSpeech.Voice voice)
        {
            string err   = null;
            string fPath = Path.Combine(QuestToSpeech.TempDirectory, string.Format("test-{0}.wav", Util.MD5Hash(testString + voice.Name + voice.Module)));

            if (!File.Exists(fPath))
            {
                if (voice.Module == QuestToSpeech.Module.Windows)
                {
                    err = WindowsTTS.Speak(testString, voice, fPath);
                }
                else if (voice.Module == QuestToSpeech.Module.Azure)
                {
                    err = AzureTTS.Speak(testString, voice, fPath, azureAPIConfig);
                }
                else if (voice.Module == QuestToSpeech.Module.Google)
                {
                    err = GoogleTTS.Speak(testString, voice, fPath);
                }
                else if (voice.Module == QuestToSpeech.Module.AWS)
                {
                    err = AwsTTS.Speak(testString, voice, fPath, awsAPIConfig);
                }
            }

            if (err != null)
            {
                MessageBox.Show(err);
                return;
            }

            if (File.Exists(fPath))
            {
                if (player != null)
                {
                    player.Stop();
                    player.Dispose();
                }

                player = new SoundPlayer(fPath);
                player.Play();
            }
        }