def get_audio_file(data: ConverterData) -> AudioSegment: if data.audio_file: return data.audio_file linked_files = data.eaf_object.get_linked_files() absolute_path_media_file = url2pathname(linked_files[0]['MEDIA_URL']) relative_path_media_file = os.path.join('/'.join(data.elan_file.split('/')[:-1]), linked_files[0]['RELATIVE_MEDIA_URL']) # TODO: Change all of this to AudioSegment.from_file(path, format) if os.path.isfile(absolute_path_media_file): audio_data = AudioSegment.from_wav(absolute_path_media_file) elif os.path.isfile(relative_path_media_file): audio_data = AudioSegment.from_wav(relative_path_media_file) else: warning_message = WarningMessage() choice = warning_message.warning(warning_message, 'Warning', f'Warning: Could not find media file {absolute_path_media_file}. ' f'Would you like to locate it manually?', QMessageBox.No | QMessageBox.Yes) found_path_audio_file = None if choice == QMessageBox.Yes: found_path_audio_file = open_audio_dialogue() if found_path_audio_file: audio_data = AudioSegment.from_wav(found_path_audio_file) else: audio_data = None return audio_data
def on_click_import(self) -> None: if self.parent.components.table: warning_message = WarningMessage() choice = warning_message.warning(warning_message, 'Warning', 'Warning: Any unsaved work will be overwritten. Proceed?', QMessageBox.Yes | QMessageBox.No) if choice == QMessageBox.No: return self.parent.load_third_stage_widgets(self.parent.components, self.parent.data)
def on_click_export(self) -> None: if self.parent.components.table.get_selected_count() == 0: warning_message = WarningMessage() warning_message.warning(warning_message, 'Warning', f'You have not selected any items to export.\n' f'Please select at least one item to continue.', QMessageBox.Yes) else: if not self.export_directory_empty(): warning_message = WarningMessage() decision = warning_message.warning(warning_message, 'Warning', f'There are already files in the selected output folder.\n' f'Existing files will be overwritten.\n' f'Are you sure you want to continue.', QMessageBox.Yes | QMessageBox.No) if decision == QMessageBox.Yes: self.parent.export_resources() else: self.parent.export_resources()
def template_fail_warn(): template_fail = WarningMessage() template_fail.warning( template_fail, 'Warning', f"Template creation failed, please contact team for support\n", QMessageBox.Ok)
def save_fail_warn(): save_fail = WarningMessage() save_fail.warning(save_fail, 'Warning', f"Save failed, please contact team for support\n", QMessageBox.Ok)
def project_open_failed(): project_load_fail = WarningMessage() project_load_fail.warning( project_load_fail, 'Warning', f'Project failed to open. Please ensure a Hermes project folder was selected.\n', QMessageBox.Ok)
def no_template_msg(): export_msg = WarningMessage() export_msg.information( export_msg, 'Warning', f"No Template Type selected, template creation aborted.\n", QMessageBox.Ok)
def export_init_msg(): export_msg = WarningMessage() export_msg.information( export_msg, 'Export Location Needed', f"Export location not set, a file dialog will now open. Please choose a location to save assets.\n", QMessageBox.Ok)
def no_export_msg(): no_save_file_warn = WarningMessage() no_save_file_warn.warning( no_save_file_warn, 'Warning', f"No export location found. You must specify an export location to save assets.\n", QMessageBox.Ok)
def no_save_file_msg(): no_save_file_warn = WarningMessage() no_save_file_warn.warning( no_save_file_warn, 'Warning', f"No save file was selected. You must specify a file to save to.\n", QMessageBox.Ok)
def file_not_found_msg(): file_not_found_warn = WarningMessage() file_not_found_warn.warning(file_not_found_warn, 'Warning', f'No file was found.\n', QMessageBox.Ok)