예제 #1
0
파일: MainForm.cs 프로젝트: digovc/voicer
        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);
        }
예제 #2
0
파일: MainForm.cs 프로젝트: digovc/voicer
        private static string GetVoiceName(Speak speak)
        {
            switch (speak.voice.voiceName)
            {
            case "maria":
                return("Microsoft Maria Desktop");

            default:
                return("Microsoft Daniel Desktop");
            }
        }
예제 #3
0
파일: MainForm.cs 프로젝트: digovc/voicer
        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();
        }
예제 #4
0
파일: MainForm.cs 프로젝트: digovc/voicer
        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);
        }
예제 #5
0
파일: MainForm.cs 프로젝트: digovc/voicer
        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);
        }