From e17e87e809248afe49c4cee6018604d681241b31 Mon Sep 17 00:00:00 2001 From: Ayo Date: Thu, 4 Sep 2025 09:48:42 +0200 Subject: [PATCH] feat: implement --skip_play --- README.md | 4 ++++ tts.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 36be6bb..79bae5d 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,10 @@ $ python tts.py --voice asmr # af_nicole $ python tts.py --voice brit # bf_emma ``` +### Disable audio player + +You can disable the built-in audio player with `--skip_play` if you choose to play the audio files generated with your preferred player. + ## Demo Outputs ### Pro (ah_heart) diff --git a/tts.py b/tts.py index b557675..1fd2001 100644 --- a/tts.py +++ b/tts.py @@ -50,6 +50,12 @@ def parse_args(): default=("cuda" if torch.cuda.is_available() else ("mps" if torch.backends.mps.is_available() else ("xpu" if torch.xpu.is_available() else "cpu"))), help="Device for inference: cuda | mps | cpu", ) + parser.add_argument( + "--skip_play", + required=False, + action="store_true", + help="Prevent playing the generated audio", + ) return parser.parse_args() def generate_audio(generator, name, voice): @@ -99,7 +105,13 @@ def main(): generator = pipeline(text, voice=voice) output_files = generate_audio(generator, name, voice) - play_audio(output_files) + if args.skip_play: + print("Audio player disabled. You can play the output files manually:", output_files) + else: + try: + play_audio(output_files) + except: + print("Something went wrong when trying to play the audio files. Try `--skip_play` and play the output files manually:", output_files) if __name__ == "__main__": main()