protected override void ExecuteAction(string ribbonId) { //TODO: This needs to improved to stop using global variables (Change RemoveAudioEnabledHandler too) this.StartNewUndoEntry(); ComputerVoiceRuntimeService.RemoveAudioFromSelectedSlides(); CustomTaskPane recorderPane = this.GetAddIn().GetActivePane(typeof(RecorderTaskPane)); if (recorderPane != null) { RecorderTaskPane recorder = recorderPane.Control as RecorderTaskPane; recorder.ClearRecordDataListForSelectedSlides(); // if current list is visible, update the pane immediately if (recorderPane.Visible) { foreach (PowerPointSlide slide in this.GetCurrentPresentation().SelectedSlides) { recorder.UpdateLists(slide.ID); } } } ComputerVoiceRuntimeService.IsRemoveAudioEnabled = false; this.GetRibbonUi().RefreshRibbonControl("RemoveNarrationsButton"); }
private void Worker_DoWorkForAudioGenerationService(object sender, DoWorkEventArgs e) { for (int i = 0; i < totalValue; i++) { if (worker.CancellationPending) { e.Cancel = true; return; } int percentage = (int)Math.Round(((double)i + 1) / totalValue * 100); ComputerVoiceRuntimeService.EmbedSlideNotes(i); (sender as BackgroundWorker).ReportProgress(percentage); } }
private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { switch (workerType) { case BackgroundWorkerType.ELearningLabService: service.SyncExitEffectAnimations(); break; case BackgroundWorkerType.AudioGenerationService: break; default: break; } Dispatcher.Invoke(() => { Close(); }); if (AudioSettingService.IsPreviewEnabled) { ComputerVoiceRuntimeService.PreviewAnimations(); } }
private void SpeakButton_Click(object sender, RoutedEventArgs e) { string textToSpeak = spokenText.Text.Trim(); if (string.IsNullOrEmpty(textToSpeak)) { return; } IVoice voice = ((Button)sender).CommandParameter as IVoice; if (voice == null) { voice = SelectedVoice; } if (voice is ComputerVoice) { ComputerVoiceRuntimeService.SpeakString(textToSpeak, voice as ComputerVoice); } else if (voice is AzureVoice && !IsSameTextSpokenBySamePerson(textToSpeak, voice.VoiceName)) { AzureRuntimeService.SpeakString(textToSpeak, voice as AzureVoice); } else if (voice is AzureVoice && IsSameTextSpokenBySamePerson(textToSpeak, voice.VoiceName)) { string dirPath = System.IO.Path.GetTempPath() + AudioService.TempFolderName; string filePath = dirPath + "\\" + string.Format(ELearningLabText.AudioPreviewFileNameFormat, voice.VoiceName); AzureRuntimeService.PlaySavedAudioForPreview(filePath); } else if (voice is WatsonVoice && !IsSameTextSpokenBySamePerson(textToSpeak, voice.VoiceName)) { WatsonRuntimeService.Speak(textToSpeak, voice as WatsonVoice); } else if (voice is WatsonVoice && IsSameTextSpokenBySamePerson(textToSpeak, voice.VoiceName)) { string dirPath = System.IO.Path.GetTempPath() + AudioService.TempFolderName; string filePath = dirPath + "\\" + string.Format(ELearningLabText.AudioPreviewFileNameFormat, voice.VoiceName); AzureRuntimeService.PlaySavedAudioForPreview(filePath); } }
public static void SaveStringToWaveFiles(string notesText, string folderPath, string fileNameFormat) { TaggedText taggedNotes = new TaggedText(notesText); List <string> stringsToSave = taggedNotes.SplitByClicks(); //MD5 md5 = MD5.Create(); for (int i = 0; i < stringsToSave.Count; i++) { string textToSave = stringsToSave[i]; string baseFileName = string.Format(fileNameFormat, i + 1); // The first item will autoplay; everything else is triggered by a click. string fileName = i > 0 ? baseFileName + " (OnClick)" : baseFileName; string filePath = folderPath + "\\" + fileName + ".wav"; switch (AudioSettingService.selectedVoiceType) { case VoiceType.ComputerVoice: ComputerVoiceRuntimeService.SaveStringToWaveFile(textToSave, filePath, AudioSettingService.selectedVoice as ComputerVoice); break; case VoiceType.AzureVoice: AzureRuntimeService.SaveStringToWaveFileWithAzureVoice(textToSave, filePath, AudioSettingService.selectedVoice as AzureVoice); break; case VoiceType.WatsonVoice: WatsonRuntimeService.SaveStringToWaveFile(textToSave, filePath, AudioSettingService.selectedVoice as WatsonVoice); break; default: break; } } }
protected override void ExecuteAction(string ribbonId) { if (AudioSettingService.selectedVoiceType == VoiceType.AzureVoice && AzureAccount.GetInstance().IsEmpty()) { MessageBox.Show("Invalid user account. Please log in again."); return; } //TODO: This needs to improved to stop using global variables this.StartNewUndoEntry(); PowerPointSlide currentSlide = this.GetCurrentSlide(); // If there are text in notes page for any of the selected slides if (this.GetCurrentPresentation().SelectedSlides.Any(slide => slide.NotesPageText.Trim() != "")) { ComputerVoiceRuntimeService.IsRemoveAudioEnabled = true; this.GetRibbonUi().RefreshRibbonControl("RemoveNarrationsButton"); } try { ComputerVoiceRuntimeService.EmbedSelectedSlideNotes(); } catch { MessageBox.Show("Failed to generate audio files."); return; } CustomTaskPane recorderPane = this.GetAddIn().GetActivePane(typeof(RecorderTaskPane)); if (recorderPane == null) { return; } RecorderTaskPane recorder = recorderPane.Control as RecorderTaskPane; if (recorder == null) { return; } // initialize selected slides' audio List <string[]> allAudioFiles = ComputerVoiceRuntimeService.ExtractSlideNotes(); recorder.InitializeAudioAndScript(this.GetCurrentPresentation().SelectedSlides.ToList(), allAudioFiles, true); // if current list is visible, update the pane immediately if (recorderPane.Visible) { recorder.UpdateLists(currentSlide.ID); } if (AudioSettingService.IsPreviewEnabled) { ComputerVoiceRuntimeService.PreviewAnimations(); } }
protected override void ExecuteAction(string ribbonId) { ComputerVoiceRuntimeService.SpeakSelectedText( AudioSettingService.selectedVoice as ComputerVoice); }