Created
March 10, 2022 06:20
-
-
Save mouseos/a850c3e9f4d7f83d80ffd95186a6913f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import re | |
| from pydub import AudioSegment | |
| #パス | |
| path = "audio/test" | |
| for current_dir, sub_dirs, files_list in os.walk(path): | |
| for file_name in files_list: | |
| file_path=(os.path.join(current_dir,file_name)) | |
| extension=(re.sub('.*\.', '', file_path)) | |
| try: | |
| sound = AudioSegment.from_file(os.path.join(current_dir,file_name), extension) | |
| time = sound.duration_seconds # 再生時間(秒) | |
| print(file_path) | |
| print('再生時間:', time) | |
| except Exception: | |
| pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment