/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes an object to read SA data from the SA database. /// </summary> /// ------------------------------------------------------------------------------------ public bool Initialize(string audioFilePath, bool isForTmpOperation) { m_doc = SaAudioDocument.Load(audioFilePath, isForTmpOperation, true); if (m_doc != null) { ResetSegmentEnumerators(); return(true); } try { using (var audioReader = new AudioReader()) { var result = audioReader.Initialize(audioFilePath); if (result == AudioReader.InitResult.FileNotFound) { ShowWaveFileNotFoundMsg(audioFilePath); return(false); } if ((result == AudioReader.InitResult.InvalidFormat)) { var msg = LocalizationManager.GetString("Miscellaneous.Messages.DataSourceReading.InvalidWaveFileMsg", "The file '{0}' is not a valid wave file."); Utils.MsgBox(string.Format(msg, Utils.PrepFilePathForMsgBox(audioFilePath))); return(false); } // If audio file is old SA format, then tell user to use SA 3.0.1 to convert first. if (audioReader.IsOldSaFormat) { if (m_worker != null) { m_worker.ReportProgress(-1); } var msg = LocalizationManager.GetString( "Miscellaneous.Messages.DataSourceReading.AudioFileNeedsConversionMsg", "It appears the audio file '{0}' may have been created using an old version " + "of Speech Analyzer. In order for {1} to read data associated with this audio " + "file it must first be converted using Speech Analyzer 3.0.1."); msg = string.Format(msg, audioFilePath, Application.ProductName); using (var dlg = new DownloadSaDlg(msg)) dlg.ShowDialog(); return(false); } // Now try reading the companion transcription file again. m_doc = SaAudioDocument.Load(audioFilePath, isForTmpOperation, false); ResetSegmentEnumerators(); } } catch (Exception e) { var msg = LocalizationManager.GetString( "Miscellaneous.Messages.DataSourceReading.ErrorInitializingSaDocumentReaderMsg", "Error initializing SA Document reader."); ErrorReport.ReportNonFatalExceptionWithMessage(e, msg); return(false); } return(true); }