""" Copyright 2024 RobotsMali AI4D Lab. Licensed under the Creative Commons Attribution 4.0 International License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://creativecommons.org/licenses/by/4.0/ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ import json import os # Hardcoded paths for the manifest files manifest_paths = { "train_bambara": "jeli-data-manifest/manifests/train_manifest.json", "test_bambara": "jeli-data-manifest/manifests/test_manifest.json", "train_french": "jeli-data-manifest/french-manifests/train_french_manifest.json", "test_french": "jeli-data-manifest/french-manifests/test_french_manifest.json", } # Directory to save the lowercase transcriptions output_dir = "lower-case-transcriptions" os.makedirs(output_dir, exist_ok=True) # Function to process a manifest file def lowercase_manifest(input_path, output_path): """Convert all transcriptions in a manifest file to lowercase.""" with open(input_path, "r", encoding="utf-8") as infile, open(output_path, "w", encoding="utf-8") as outfile: for line in infile: entry = json.loads(line) entry["text"] = entry["text"].lower() outfile.write(json.dumps(entry, ensure_ascii=False) + "\n") # Process each manifest file for key, input_path in manifest_paths.items(): output_path = os.path.join(output_dir, os.path.basename(input_path)) lowercase_manifest(input_path, output_path) print(f"Processed {input_path} and saved to {output_path}") print("All manifest files have been processed.")