Skip to content

Commit

Permalink
refactor: Fix minor linting issues (#89)
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzalo-bulnes authored Jan 3, 2024
1 parent fd3c64b commit 3093192
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
14 changes: 8 additions & 6 deletions build-checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -30,6 +30,7 @@ def checkCSVcolumnCount():
else:
return 0


def checkFilenameLengths():
print("SOUNDS: Checking file name lengths ...")
invalid_filename_found = False
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -76,14 +77,15 @@ 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:
return 1
else:
return 0


def checkForDuplicateStringID():
print("VOICES: Check for duplicate StringIDs ...")
duplicate_found = False
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 3 additions & 7 deletions voice-gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import re
import sys
import time
import subprocess
from pathlib import Path

try:
Expand All @@ -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)


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3093192

Please sign in to comment.