private void Convert(string filename, Options options, ConvertorFactory.SupportedType supportedType) { var strategy = new SpeechLibStrategy(options, 4, supportedType); var voices = strategy.GetVoiceNames().ToList(); Assert.IsTrue(voices.Count() == 2, "voices: " + string.Join(", ", voices)); var model = new TextToVoiceModel { CurrentState = TextToVoiceModel.States.Run, OutFilePath = filename, FilePath = filename }; model.SetText(testText); strategy.Execute(model, voices.Last()); }
public void Execute(TextToVoiceModel model, string voiceName) { using (var converter = ConvertorFactory.GetConverter(model.OutFilePath, _options, _supportedType)) { while (model.CurrentLine < model.TextLines.Length && model.CurrentState == TextToVoiceModel.States.Run) { var textLine = model.TextLines[model.CurrentLine]; var wavData = GetBytes(textLine); converter.ConvertAsyn(wavData); model.CurrentLine++; } if (model.CurrentLine == model.TextLines.Length) { model.CurrentState = TextToVoiceModel.States.Done; } } }
public void Execute(TextToVoiceModel model, string voiceName) { throw new NotImplementedException(); }
public void Pause(TextToVoiceModel model) { if (model.CurrentState == TextToVoiceModel.States.Run && _thread.IsAlive) { model.CurrentState = TextToVoiceModel.States.Paused; } }
public void Add(string fileFullNames) { var model = new TextToVoiceModel { FilePath = fileFullNames }; model.OutFilePath = Path.Combine(Properties.Settings.Default.PathToVoiceRep, model.NameWithoutExtension); _models.Add(model); }
public void Start(TextToVoiceModel model) { if (model.CurrentState == TextToVoiceModel.States.Paused || model.CurrentState == TextToVoiceModel.States.Wait) { if (_thread != null && _thread.IsAlive) { var rModel = _models.FirstOrDefault(m => m.CurrentState == TextToVoiceModel.States.Run); if (rModel != null) { rModel.CurrentState = TextToVoiceModel.States.Paused; } } model.CurrentState = TextToVoiceModel.States.Runing; } if (_timer == null) { _timer = new Timer(Execute, null, new TimeSpan(0, 0, 1), new TimeSpan(0, 0, 1)); } }
public void Remove(TextToVoiceModel model) { model.CurrentState = TextToVoiceModel.States.Aborted; _models.Remove(model); }