Downloads sample wav files from non-restricted AWS S3 bucket.
(over_write=False, small_only=True)
| 104 | |
| 105 | @staticmethod |
| 106 | def load_voice_sample_files(over_write=False, small_only=True): |
| 107 | |
| 108 | """ Downloads sample wav files from non-restricted AWS S3 bucket. """ |
| 109 | |
| 110 | if not os.path.exists(LLMWareConfig.get_llmware_path()): |
| 111 | LLMWareConfig.setup_llmware_workspace() |
| 112 | |
| 113 | # not configurable - will pull into /sample_files under llmware_path |
| 114 | if not small_only: |
| 115 | sample_files_path = os.path.join(LLMWareConfig.get_llmware_path(), "voice_sample_files") |
| 116 | else: |
| 117 | sample_files_path = os.path.join(LLMWareConfig.get_llmware_path(), "voice_sample_files_small") |
| 118 | |
| 119 | if not os.path.exists(sample_files_path): |
| 120 | os.makedirs(sample_files_path, exist_ok=True) |
| 121 | else: |
| 122 | if not over_write: |
| 123 | logger.info(f"Setup - voice_sample_files path already exists - {sample_files_path}") |
| 124 | return sample_files_path |
| 125 | |
| 126 | # pull from sample files bucket |
| 127 | bucket_name = LLMWareConfig().get_config("llmware_sample_files_bucket") |
| 128 | |
| 129 | if small_only: |
| 130 | folder_name = "voice_small" |
| 131 | else: |
| 132 | folder_name = "voice_all" |
| 133 | |
| 134 | logger.info("Setup - sample_voice_files - downloading requested sample files from AW3 S3 bucket - " |
| 135 | "may take a minute.") |
| 136 | |
| 137 | remote_zip = folder_name + ".zip" |
| 138 | local_zip = os.path.join(sample_files_path, bucket_name + ".zip") |
| 139 | |
| 140 | CloudBucketManager().pull_file_from_public_s3(remote_zip, local_zip, bucket_name) |
| 141 | shutil.unpack_archive(local_zip, sample_files_path, "zip") |
| 142 | os.remove(local_zip) |
| 143 | |
| 144 | return sample_files_path |
| 145 | |
| 146 | @staticmethod |
| 147 | def load_selected_sample_files(sample_folder="microsoft_ir", over_write=False): |