Skip to content

Commit

Permalink
Allow custom voice list to be passed to VoiceManager
Browse files Browse the repository at this point in the history
* Useful so that the application could cache the list.
* Bump to version 6.1.x
  • Loading branch information
rany2 committed Jan 9, 2023
1 parent bd9cc2b commit d95b5d3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = edge-tts
version = 6.0.9
version = 6.1.0
author = rany
author_email = [email protected]
description = Microsoft Edge's TTS
Expand Down
2 changes: 1 addition & 1 deletion src/edge_tts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
"exceptions",
"list_voices",
]
__version__ = "6.0.7"
__version__ = "6.1"
6 changes: 4 additions & 2 deletions src/edge_tts/list_voices.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,14 @@ def __init__(self) -> None:
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
Expand Down

0 comments on commit d95b5d3

Please sign in to comment.