diff --git a/README.md b/README.md index f7b882b..8ebb045 100644 --- a/README.md +++ b/README.md @@ -68,8 +68,8 @@ Support for custom SSML has been removed since 5.0.0 because Microsoft has taken It is possible to make minor changes to the generated speech. $ edge-tts --pitch=-10Hz --text "Hello, world!" --write-media hello_with_pitch_down.mp3 - $ edge-tts --rate=0.5 --text "Hello, world!" --write-media hello_with_rate_halved.mp3 - $ edge-tts --volume=50 --text "Hello, world!" --write-media hello_with_volume_halved.mp3 + $ edge-tts --rate=-50% --text "Hello, world!" --write-media hello_with_rate_halved.mp3 + $ edge-tts --volume=-50% --text "Hello, world!" --write-media hello_with_volume_halved.mp3 Keep in mind that the `--pitch`, `--rate`, `--volume`, etc. options are applied to the entire SSML document. diff --git a/src/edge_tts/communicate.py b/src/edge_tts/communicate.py index 3ea391c..fe8f95f 100644 --- a/src/edge_tts/communicate.py +++ b/src/edge_tts/communicate.py @@ -231,15 +231,15 @@ class Communicate: ): raise ValueError(f"Invalid voice '{voice}'.") - if re.match(r"^[+-]\d+Hz$", pitch) is None: + if re.match(r"^[+-]?\d+Hz$", pitch) is None: raise ValueError(f"Invalid pitch '{pitch}'.") self.pitch: str = pitch - if re.match(r"^[+-]0*([0-9]|([1-9][0-9])|100)%$", rate) is None: + if re.match(r"^[+-]?\d+%$", rate) is None: raise ValueError(f"Invalid rate '{rate}'.") self.rate: str = rate - if re.match(r"^[+-]0*([0-9]|([1-9][0-9])|100)%$", volume) is None: + if re.match(r"^[+-]?\d+%$", volume) is None: raise ValueError(f"Invalid volume '{volume}'.") self.volume: str = volume