diff --git a/build-checks.py b/build-checks.py index dcfb8fb7..88ba4281 100755 --- a/build-checks.py +++ b/build-checks.py @@ -21,7 +21,7 @@ def checkCSVcolumnCount(): reader = csv.reader(open(f, "r")) for row in reader: if not len(row) == 6: - print("{}: Insufficient columns of data - {}".format(filename, row)) + print(f"{filename}: Insufficient columns of data - {row}") missing_csv_field = True continue @@ -30,6 +30,7 @@ def checkCSVcolumnCount(): else: return 0 + def checkFilenameLengths(): print("SOUNDS: Checking file name lengths ...") invalid_filename_found = False @@ -38,12 +39,12 @@ def checkFilenameLengths(): path = os.path.join(dirpath, fn) if path.split(os.path.sep)[2] == "SYSTEM": if len(os.path.splitext(fn)[0]) > 8: - print("Filename too long for a SYSTEM file: {}".format(path)) + print(f"Filename too long for a SYSTEM file: {path}") invalid_filename_found = True elif path.split(os.path.sep)[2] == "SCRIPTS": continue elif len(os.path.splitext(fn)[0]) > 6: - print("Filename too long for a non-SYSTEM file: {}".format(path)) + print(f"Filename too long for a non-SYSTEM file: {path}") invalid_filename_found = True if invalid_filename_found: @@ -60,7 +61,7 @@ def checkNoZeroByteFiles(): for fn in files: path = os.path.join(root, fn) if os.stat(path).st_size == 0: - print("Zero byte file: {}".format(path)) + print(f"Zero byte file: {path}") zero_byte_file_found = True if zero_byte_file_found: @@ -76,7 +77,7 @@ def validateSoundsJson(): try: json.load(f) except ValueError as err: - print("JSON not valid: {}".format(str(err))) + print(f"JSON not valid: {str(err)}") invalid_json_found = True if invalid_json_found: @@ -84,6 +85,7 @@ def validateSoundsJson(): else: return 0 + def checkForDuplicateStringID(): print("VOICES: Check for duplicate StringIDs ...") duplicate_found = False @@ -111,7 +113,7 @@ def checkForDuplicateStringID(): else: StringID = row[0] if StringID in StringID_count.keys(): - print('{}: {} is duplicated'.format(f, StringID)) + print(f'{f}: {StringID} is duplicated') StringID_count[StringID] = StringID_count[StringID] + 1 duplicate_found = True else: diff --git a/voice-gen.py b/voice-gen.py index 05556aa6..b552a85b 100755 --- a/voice-gen.py +++ b/voice-gen.py @@ -5,7 +5,6 @@ import re import sys import time -import subprocess from pathlib import Path try: @@ -17,7 +16,6 @@ https://docs.microsoft.com/azure/cognitive-services/speech-service/quickstart-text-to-speech-python for installation instructions. """) - import sys sys.exit(1) @@ -125,7 +123,7 @@ def main() -> None: speech_config = speechsdk.SpeechConfig(subscription=speech_key, region=service_region) - if not(os.path.isfile(csv_file)): + if not os.path.isfile(csv_file): print("Error: voice file not found") sys.exit(1) @@ -181,11 +179,9 @@ def main() -> None: # If failed, show error, remove empty/corrupt file and halt if result.reason == speechsdk.ResultReason.Canceled: cancellation_details = result.cancellation_details - print("Speech synthesis canceled: {}".format( - cancellation_details.reason)) + print(f"Speech synthesis canceled: {cancellation_details.reason}") if cancellation_details.reason == speechsdk.CancellationReason.Error: - print("Error details: {}".format( - cancellation_details.error_details)) + print(f"Error details: {cancellation_details.error_details}") if os.path.isfile(outdir + os.sep + filename): os.remove(outdir + os.sep + filename) sys.exit(1)