(url: str, key: str = None)
| 263 | |
| 264 | |
| 265 | def generate_scp_for_sv(url: str, key: str = None): |
| 266 | wav_scp_path = None |
| 267 | wav_name = key if key is not None else os.path.basename(url) |
| 268 | # for local wav.scp inputs |
| 269 | if os.path.exists(url) and url.lower().endswith('.scp'): |
| 270 | wav_scp_path = url |
| 271 | return wav_scp_path |
| 272 | # for local wav file inputs |
| 273 | if os.path.exists(url) and (url.lower().endswith(SUPPORT_AUDIO_TYPE_SETS)): |
| 274 | wav_path = url |
| 275 | work_dir = tempfile.TemporaryDirectory().name |
| 276 | if not os.path.exists(work_dir): |
| 277 | os.makedirs(work_dir) |
| 278 | wav_scp_path = os.path.join(work_dir, 'wav.scp') |
| 279 | with open(wav_scp_path, 'w') as ft: |
| 280 | scp_content = '\t'.join([wav_name, wav_path]) + '\n' |
| 281 | ft.writelines(scp_content) |
| 282 | return wav_scp_path |
| 283 | # for wav url, download and generate wav.scp |
| 284 | result = urlparse(url) |
| 285 | if result.scheme is not None and len(result.scheme) > 0: |
| 286 | storage = HTTPStorage() |
| 287 | wav_scp_path = storage.read(url) |
| 288 | return wav_scp_path |
| 289 | |
| 290 | return wav_scp_path |
| 291 | |
| 292 | |
| 293 | def generate_sv_scp_from_url(urls: Union[tuple, list]): |
no test coverage detected
searching dependent graphs…