Exemplo n.º 1
0
        private void SaveLipSync(Speak speak)
        {
            var lipSync = GetLipSync(speak.phonemes);
            var file    = string.Format("{0}\\{1}.dat",
                                        Path.GetDirectoryName(speak.waveFile),
                                        Path.GetFileNameWithoutExtension(speak.waveFile));

            File.WriteAllText(file, lipSync);
        }
Exemplo n.º 2
0
        private static string GetVoiceName(Speak speak)
        {
            switch (speak.voice.voiceName)
            {
            case "maria":
                return("Microsoft Maria Desktop");

            default:
                return("Microsoft Daniel Desktop");
            }
        }
Exemplo n.º 3
0
        private void Synthesize(Speak speak, List <Phoneme> phonemes)
        {
            var format = new SpeechAudioFormatInfo(EncodingFormat.Pcm, 16000, 16, 1, 32000, 2, null);
            var synth  = new SpeechSynthesizer {
                Rate = speak.voice.rate
            };

            synth.SelectVoice(GetVoiceName(speak));
            synth.SetOutputToWaveFile(speak.waveFile, format);
            synth.PhonemeReached += (s, e) => PhonemeReached(e, phonemes);
            synth.Speak(speak.text);
            synth.Dispose();
        }
Exemplo n.º 4
0
        private void export(Speak speak, int index)
        {
            var file = string.Format("{0}\\speak_{1}_{2}.wav",
                                     folderBrowserDialog.SelectedPath,
                                     index.ToString("d3"),
                                     speak.character);

            speak.waveFile = file;
            var phonemes = new List <Phoneme>();

            Synthesize(speak, phonemes);
            speak.phonemes = phonemes.ToArray();
            SaveLipSync(speak);
        }
Exemplo n.º 5
0
        private void AddSpeak(List <Speak> speaks, string line, IEnumerable <Voice> voices)
        {
            var parts = line.Split(':');

            if (parts.Length != 2)
            {
                throw new Exception("Invalid speak: " + line);
            }

            var speak = new Speak
            {
                character = parts[0]?.Trim(),
                text      = parts[1].Trim()
            };

            speak.voice = voices.FirstOrDefault(x => x.character == speak.character) ?? voices.First();
            speaks.Add(speak);
        }