private static PromptBuilder GetPromptForText(string textToConvert, ComputerVoice voice) { TaggedText taggedText = new TaggedText(textToConvert); PromptBuilder builder = taggedText.ToPromptBuilder(voice.ToString()); return(builder); }
public void TestClone() { ComputerVoice voice_expected = new ComputerVoice("computer voice"); ComputerVoice voice_actual = computerVoice.Clone() as ComputerVoice; Assert.AreEqual(voice_expected.Rank, voice_actual.Rank); Assert.AreEqual(voice_expected.Voice, voice_actual.Voice); }
public static void SpeakString(string textToSpeak, ComputerVoice voice) { if (string.IsNullOrWhiteSpace(textToSpeak)) { return; } PromptBuilder builder = GetPromptForText(textToSpeak, voice); PromptToAudio.Speak(builder); }
private static void SpeakText(string textToSpeak, ComputerVoice voice) { try { SpeakString(textToSpeak, voice); } catch (InvalidOperationException) { ErrorParsingText(); } }
private static void InitComputerVoice(ComputerVoice target, string racePath) { WWW www; if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "lowResources.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "lowResources.wav"))); target.lowResources = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "lowCrew.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "lowCrew.wav"))); target.lowCrew = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "stationConstructingBegan.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "stationConstructingBegan.wav"))); target.stationConstructingBegan = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "shipConstructingBegan.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "shipConstructingBegan.wav"))); target.shipConstructingBegan = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "stationConstructingEnd.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "stationConstructingEnd.wav"))); target.stationConstructingEnd = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "shipConstructingEnd.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "shipConstructingEnd.wav"))); target.shipConstructingEnd = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "constructingCanseled.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "constructingCanseled.wav"))); target.constructingCanseled = www.GetAudioClip(); } if (Directory.Exists(Path.Combine(mainPath, Path.Combine(racePath, "isUnderAttack.wav")))) { www = new WWW(Path.Combine(mainPath, Path.Combine(racePath, "isUnderAttack.wav"))); target.isUnderAttack = www.GetAudioClip(); } }
private void CancelButton_Click(object sender, RoutedEventArgs e) { if (audioListView.IsVisible) { List <IVoice> rankedAudioListCacheCopy = rankedAudioListCache.Select(x => (IVoice)x.Clone()).ToList(); AudioSettingService.preferredVoices = new ObservableCollection <IVoice>(rankedAudioListCacheCopy); } if ((AudioSettingService.selectedVoiceType == VoiceType.AzureVoice && !AzureRuntimeService.IsAzureAccountPresent()) || (AudioSettingService.selectedVoiceType == VoiceType.WatsonVoice && !WatsonRuntimeService.IsWatsonAccountPresent())) { ComputerVoice defaultVoiceSelected = computerVoiceComboBox.SelectedItem as ComputerVoice; DialogConfirmedHandler(VoiceType.ComputerVoice, defaultVoiceSelected, previewCheckbox.IsChecked.GetValueOrDefault()); } }
public static void SpeakSelectedText(ComputerVoice voice) { try { string selected = Globals.ThisAddIn.Application.ActiveWindow.Selection.TextRange.Text.Trim(); List <string> splitScript = (new TaggedText(selected)).SplitByClicks(); StringBuilder completeTextBuilder = new StringBuilder(); Regex reg = new Regex("\\.+\\s*"); foreach (string text in splitScript) { completeTextBuilder.Append(reg.Replace(text, string.Empty)); completeTextBuilder.Append(". "); } SpeakText(completeTextBuilder.ToString(), voice); } catch (COMException) { // Nothing was selected. } }
public static void SaveStringToWaveFile(string textToSave, string filePath, ComputerVoice voice) { PromptBuilder builder = GetPromptForText(textToSave, voice); PromptToAudio.SaveAsWav(builder, filePath); }
public void Init() { computerVoice = new ComputerVoice("computer voice"); }