mirror of
https://github.com/ml-explore/mlx-examples.git
synced 2025-08-29 06:54:39 +08:00
cli: align directory handling with codebase style
Use warnings.warn() for errors instead of print(), show file count messages only with --verbose, and simplify user prompts. Keep error handling consistent with the original code, including traceback on exceptions.
This commit is contained in:
parent
cde50ec846
commit
2dff75fba5
@ -167,13 +167,13 @@ def build_parser():
|
|||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--prepend-punctuations",
|
"--prepend-punctuations",
|
||||||
type=str,
|
type=str,
|
||||||
default="\"'“¿([{-",
|
default="\"'""¿([{-",
|
||||||
help="If word-timestamps is True, merge these punctuation symbols with the next word",
|
help="If word-timestamps is True, merge these punctuation symbols with the next word",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--append-punctuations",
|
"--append-punctuations",
|
||||||
type=str,
|
type=str,
|
||||||
default="\"'.。,,!!??::”)]}、",
|
default="\"'.。,,!!??::"")]}、",
|
||||||
help="If word_timestamps is True, merge these punctuation symbols with the previous word",
|
help="If word_timestamps is True, merge these punctuation symbols with the previous word",
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -273,9 +273,8 @@ def main():
|
|||||||
)
|
)
|
||||||
writer(result, file_path.stem, **writer_args)
|
writer(result, file_path.stem, **writer_args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
warnings.warn(f"Failed to process {file_path}: {str(e)}")
|
warnings.warn(f"Failed to process {file_path}: {str(e)}")
|
||||||
if args.get("verbose"):
|
|
||||||
traceback.print_exc()
|
|
||||||
continue
|
continue
|
||||||
output_name = output_name or path.stem
|
output_name = output_name or path.stem
|
||||||
|
|
||||||
@ -287,9 +286,8 @@ def main():
|
|||||||
)
|
)
|
||||||
writer(result, output_name, **writer_args)
|
writer(result, output_name, **writer_args)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
warnings.warn(f"Failed to process {audio_obj}: {str(e)}")
|
warnings.warn(f"Failed to process {audio_obj}: {str(e)}")
|
||||||
if args.get("verbose"):
|
|
||||||
traceback.print_exc()
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
Reference in New Issue
Block a user