00001 00002 // Name: batchencoder.h 00003 // Purpose: A class to convert a number of text files to WAV and then to 00004 // MP3. 00005 // Author: Julian Smart 00006 // Modified by: 00007 // Created: 2009-02-10 00008 // RCS-ID: 00009 // Copyright: (c) Julian Smart 00010 // Licence: New BSD License 00012 00013 #ifndef _BATCHENCODER_H_ 00014 #define _BATCHENCODER_H_ 00015 00016 /* 00017 * Includes 00018 */ 00019 00020 #include "tts/tts.h" 00021 #include "tts/mp3encoder.h" 00022 00023 /* 00024 * Styles and types 00025 */ 00026 00027 typedef enum { 00028 wxBATCHMP3ENCODER_STATUS_IDLE, 00029 wxBATCHMP3ENCODER_STATUS_STARTING, 00030 wxBATCHMP3ENCODER_STATUS_TTS, 00031 wxBATCHMP3ENCODER_STATUS_ENCODING_MP3 00032 } wxBatchTextToMP3EncoderStatus; 00033 00034 #define wxBATCHMP3ENCODER_OPTION_ENCODE_MP3 1 00035 00036 #define wxBATCHMP3ENCODER_VERBOSITY_ERRORS 0 00037 #define wxBATCHMP3ENCODER_VERBOSITY_ERRORS_AND_WARNINGS 1 00038 #define wxBATCHMP3ENCODER_VERBOSITY_VERBOSE 2 00039 00048 class wxBatchTextToMP3EncoderProcess; 00049 00050 class wxBatchTextToMP3Encoder: public wxEvtHandler 00051 { 00052 DECLARE_DYNAMIC_CLASS( wxBatchTextToMP3Encoder ) 00053 00054 public: 00055 // Constructors 00056 00057 wxBatchTextToMP3Encoder(); 00058 ~wxBatchTextToMP3Encoder(); 00059 00060 // Operations 00061 00063 void Init(); 00064 00066 virtual bool SetData(const wxArrayString& textFilenames, const wxArrayString& audioFilenames, const wxID3InfoArray& infoArray); 00067 00069 virtual bool Start(int options = 0, wxString* log = NULL); 00070 00074 virtual bool Process(wxString* log = NULL, bool* finished = NULL); 00075 00077 virtual bool IsBusy() { return (m_textToSpeech.IsSpeaking() || m_mp3Encoder.IsEncoding() || m_status != wxBATCHMP3ENCODER_STATUS_IDLE); } 00078 00080 virtual bool Stop(); 00081 00083 void SetOptions(int options) { m_options = options; } 00084 int GetOptions() const { return m_options; } 00085 00087 //void SetEspeakOptions(int options) { m_espeakOptions = options; } 00088 //int GetEspeakOptions() const { return m_espeakOptions; } 00089 00091 void SetMP3EncoderOptions(int options) { m_mp3EncoderOptions = options; } 00092 int GetMP3EncoderOptions() const { return m_mp3EncoderOptions; } 00093 00095 wxTextToSpeech& GetSpeech() { return m_textToSpeech; } 00096 const wxTextToSpeech& GetSpeech() const { return m_textToSpeech; } 00097 00099 wxMP3Encoder& GetMP3Encoder() { return m_mp3Encoder; } 00100 const wxMP3Encoder& GetMP3Encoder() const { return m_mp3Encoder; } 00101 00103 void SetCurrentFile(int currentFile) { m_currentFile = currentFile; } 00104 int GetCurrentFile() const { return m_currentFile; } 00105 00107 void SetStatus(wxBatchTextToMP3EncoderStatus status) { m_status = status; } 00108 wxBatchTextToMP3EncoderStatus GetStatus() const { return m_status; } 00109 00111 void SetFrame(wxFrame* frame, int statusField = 0) { m_frame = frame; m_statusField = statusField; } 00112 wxFrame* GetFrame() const { return m_frame; } 00113 00115 void SetVerbosity(int verbosity) { m_verbosity = verbosity; } 00116 int GetVerbosity() const { return m_verbosity; } 00117 00118 const wxArrayString& GetTextFilenames() const { return m_textFilenames; } 00119 const wxArrayString& GetOutputFilenames() const { return m_outputFilenames; } 00120 const wxID3InfoArray& GetID3InfoArray() const { return m_infoArray; } 00121 00122 protected: 00123 int m_options; // remember the options 00124 //int m_espeakOptions; 00125 int m_mp3EncoderOptions; 00126 00127 wxTextToSpeech m_textToSpeech; 00128 wxMP3Encoder m_mp3Encoder; 00129 00130 wxArrayString m_textFilenames; 00131 wxArrayString m_outputFilenames; 00132 wxID3InfoArray m_infoArray; 00133 00134 int m_currentFile; 00135 wxBatchTextToMP3EncoderStatus m_status; 00136 00137 wxFrame* m_frame; 00138 int m_statusField; 00139 int m_verbosity; // 0 - errors only, 1 - errors and warnings, 2 - verbose 00140 }; 00141 00142 #endif 00143 // _BATCHENCODER_H_ 00144