feat: implement --skip_play
This commit is contained in:
parent
0c36335867
commit
e17e87e809
2 changed files with 17 additions and 1 deletions
|
@ -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)
|
||||
|
|
12
tts.py
12
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)
|
||||
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()
|
||||
|
|
Loading…
Reference in a new issue