Allow custom voice list to be passed to VoiceManager

* Useful so that the application could cache the list.
* Bump to version 6.1.x
This commit is contained in:
rany2
2023-01-09 18:31:53 +02:00
parent bd9cc2bd2d
commit d95b5d339f
3 changed files with 6 additions and 4 deletions

View File

@@ -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