From d95b5d339fa669a6b3520a2642334362c34ce2cf Mon Sep 17 00:00:00 2001 From: rany2 Date: Mon, 9 Jan 2023 18:31:53 +0200 Subject: [PATCH] Allow custom voice list to be passed to VoiceManager * Useful so that the application could cache the list. * Bump to version 6.1.x --- setup.cfg | 2 +- src/edge_tts/__init__.py | 2 +- src/edge_tts/list_voices.py | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/setup.cfg b/setup.cfg index 1e85359..86ccc0d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = edge-tts -version = 6.0.9 +version = 6.1.0 author = rany author_email = ranygh@riseup.net description = Microsoft Edge's TTS diff --git a/src/edge_tts/__init__.py b/src/edge_tts/__init__.py index c5ff1ff..b345f9d 100644 --- a/src/edge_tts/__init__.py +++ b/src/edge_tts/__init__.py @@ -14,4 +14,4 @@ __all__ = [ "exceptions", "list_voices", ] -__version__ = "6.0.7" +__version__ = "6.1" diff --git a/src/edge_tts/list_voices.py b/src/edge_tts/list_voices.py index 9793b5d..96557c4 100644 --- a/src/edge_tts/list_voices.py +++ b/src/edge_tts/list_voices.py @@ -52,12 +52,14 @@ class VoicesManager: self.called_create: bool = False @classmethod - async def create(cls: Any) -> "VoicesManager": + async def create( + cls: Any, custom_voices: Optional[List[Dict[str, Any]]] = None + ) -> Any: """ Creates a VoicesManager object and populates it with all available voices. """ self = VoicesManager() - self.voices = await list_voices() + self.voices = await list_voices() if custom_voices is None else custom_voices self.voices = [ {**voice, **{"Language": voice["Locale"].split("-")[0]}} for voice in self.voices