From 142bc58a268eb28559e7690ed206c76df0d7d1fd Mon Sep 17 00:00:00 2001 From: Mikolaj Holysz Date: Tue, 7 Nov 2023 11:56:44 +0100 Subject: [PATCH] Significantly improve audio quality when exporting to mp3 --- ospeak/cli.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ospeak/cli.py b/ospeak/cli.py index 2084e9c..1490b7c 100644 --- a/ospeak/cli.py +++ b/ospeak/cli.py @@ -25,7 +25,9 @@ def stream_and_play( if speak: play(audio) if output: - audio.export(output, format=output.rsplit(".", 1)[-1]) + format = output.rsplit(".", 1)[-1] + bitrate = "160k" if format == "mp3" else None # we get 160k from the API + audio.export(output, format=format, bitrate=bitrate) @click.command()