| 1149 | # TODO make the mp3 to wave a funciton and not duplicated |
| 1150 | def audio_integrity(output_dir): |
| 1151 | def check_wav_properties(f, filename): |
| 1152 | try: |
| 1153 | with wave.open(f, "rb") as wav_file: |
| 1154 | integrity_dir = os.path.join(results_folder, "audio_integrity") |
| 1155 | os.makedirs(integrity_dir, exist_ok=True) |
| 1156 | out_file = os.path.join(integrity_dir, f"{os.path.splitext(filename)[0]}.txt") |
| 1157 | with open(out_file, "w") as log: |
| 1158 | log.write(f"Channels: {wav_file.getnchannels()}\n") |
| 1159 | log.write(f"Frame rate: {wav_file.getframerate()}\n") |
| 1160 | log.write(f"Sample width: {wav_file.getsampwidth()}\n") |
| 1161 | log.write(f"Frames: {wav_file.getnframes()}\n") |
| 1162 | prGreen(f"[AUDIO INTEGRITY] Checked {filename}") |
| 1163 | except Exception as e: |
| 1164 | prRed(f"[AUDIO INTEGRITY] Failed to read {filename}: {e}") |
| 1165 | |
| 1166 | wav_dir = os.path.join(output_dir, "wav") |
| 1167 | if os.path.isdir(wav_dir): |