Downloads sample wav files from non-restricted AWS S3 bucket.
(sample_folder="microsoft_ir", over_write=False)
| 145 | |
| 146 | @staticmethod |
| 147 | def load_selected_sample_files(sample_folder="microsoft_ir", over_write=False): |
| 148 | |
| 149 | """ Downloads sample wav files from non-restricted AWS S3 bucket. """ |
| 150 | |
| 151 | if not os.path.exists(LLMWareConfig.get_llmware_path()): |
| 152 | LLMWareConfig.setup_llmware_workspace() |
| 153 | |
| 154 | # not configurable - will pull into /sample_files under llmware_path |
| 155 | sample_files_path = os.path.join(LLMWareConfig.get_llmware_path(), sample_folder) |
| 156 | |
| 157 | if not os.path.exists(sample_files_path): |
| 158 | os.makedirs(sample_files_path, exist_ok=True) |
| 159 | else: |
| 160 | if not over_write: |
| 161 | logger.info(f"Setup - sample_files selected path already exists - {sample_files_path}") |
| 162 | return sample_files_path |
| 163 | |
| 164 | # pull from sample files bucket |
| 165 | bucket_name = LLMWareConfig().get_config("llmware_sample_files_bucket") |
| 166 | |
| 167 | folder_name = sample_folder |
| 168 | |
| 169 | logger.info("Setup - selected sample files - downloading requested sample files from AW3 S3 bucket - " |
| 170 | "may take a minute.") |
| 171 | |
| 172 | remote_zip = folder_name + ".zip" |
| 173 | local_zip = os.path.join(sample_files_path, bucket_name + ".zip") |
| 174 | |
| 175 | CloudBucketManager().pull_file_from_public_s3(remote_zip, local_zip, bucket_name) |
| 176 | shutil.unpack_archive(local_zip, sample_files_path, "zip") |
| 177 | os.remove(local_zip) |
| 178 | |
| 179 | return sample_files_path |
no test coverage detected