예제 #1
0
        public static void ConvertWaveToMp3(string FullPathWave, string FullPathMp3)
        {
            string          LameFullPath = "";
            WaveToMp3Preset Preset       = WaveToMp3Preset.Cbr064;

            ConvertWaveToMp3(FullPathWave, FullPathMp3, LameFullPath, Preset);
        }
예제 #2
0
파일: CTts.cs 프로젝트: doctorgu/MadeIn9
        public void SaveAsMp3(string Ssml, bool UseThread, string FullPathMp3, string LameFullPath, WaveToMp3Preset Preset)
        {
            string FullPathWave = CPath.GetNumberedFullPath(Path.Combine(Path.GetDirectoryName(FullPathMp3), Path.GetFileNameWithoutExtension(FullPathMp3) + ".wav"));

            if (UseThread)
            {
                Thread t = new Thread(() =>
                {
                    using (SpeechSynthesizer ss = new SpeechSynthesizer())
                    {
                        ss.SetOutputToWaveFile(FullPathWave);
                        ss.SpeakSsml(Ssml);
                    }
                });
                t.Start();
                t.Join();
            }
            else
            {
                using (SpeechSynthesizer ss = new SpeechSynthesizer())
                {
                    ss.SetOutputToWaveFile(FullPathWave);
                    ss.SpeakSsml(Ssml);
                }
            }

            CAudio.ConvertWaveToMp3(FullPathWave, FullPathMp3, LameFullPath, Preset);
            File.Delete(FullPathWave);
        }
예제 #3
0
        public static void ConvertWaveToMp3(string FullPathWave, string FullPathMp3, string LameFullPath, WaveToMp3Preset Preset)
        {
            if (string.IsNullOrEmpty(LameFullPath))
            {
                LameFullPath = "lame.exe";
            }

            //lame.exe --preset cbr 256 test.wav test.mp3
            //lame.exe --preset fast standard test.wav test.mp3
            string           sPreset   = CEnum.GetDescriptionByValue <WaveToMp3Preset>(Preset);
            Process          p         = new Process();
            string           Arguments = string.Format(@"--preset {0} ""{1}"" ""{2}""", sPreset, FullPathWave, FullPathMp3);
            ProcessStartInfo ps        = new ProcessStartInfo(LameFullPath, Arguments);

            ps.WindowStyle = ProcessWindowStyle.Hidden;
            p.StartInfo    = ps;
            p.Start();
            p.WaitForExit(10000);
        }