-
-
Notifications
You must be signed in to change notification settings - Fork 678
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use TypedDict for voice list and TTS stream
Signed-off-by: rany <[email protected]>
- Loading branch information
Showing
4 changed files
with
115 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,6 @@ | |
install_requires=[ | ||
"aiohttp>=3.8.0", | ||
"certifi>=2023.11.17", | ||
"typing-extensions>=4.1.0", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
"""Custom types for edge-tts.""" | ||
|
||
# pylint: disable=too-few-public-methods | ||
|
||
from typing import List | ||
|
||
from typing_extensions import Literal, NotRequired, TypedDict | ||
|
||
|
||
class TTSChunk(TypedDict): | ||
"""TTS chunk data.""" | ||
|
||
type: Literal["audio", "WordBoundary"] | ||
data: NotRequired[bytes] # only for audio | ||
duration: NotRequired[float] # only for WordBoundary | ||
offset: NotRequired[float] # only for WordBoundary | ||
text: NotRequired[str] # only for WordBoundary | ||
|
||
|
||
class VoiceTag(TypedDict): | ||
"""VoiceTag data.""" | ||
|
||
ContentCategories: List[ | ||
Literal[ | ||
"Cartoon", | ||
"Conversation", | ||
"Copilot", | ||
"Dialect", | ||
"General", | ||
"News", | ||
"Novel", | ||
"Sports", | ||
] | ||
] | ||
VoicePersonalities: List[ | ||
Literal[ | ||
"Approachable", | ||
"Authentic", | ||
"Authority", | ||
"Bright", | ||
"Caring", | ||
"Casual", | ||
"Cheerful", | ||
"Clear", | ||
"Comfort", | ||
"Confident", | ||
"Considerate", | ||
"Conversational", | ||
"Cute", | ||
"Expressive", | ||
"Friendly", | ||
"Honest", | ||
"Humorous", | ||
"Lively", | ||
"Passion", | ||
"Pleasant", | ||
"Positive", | ||
"Professional", | ||
"Rational", | ||
"Reliable", | ||
"Sincere", | ||
"Sunshine", | ||
"Warm", | ||
] | ||
] | ||
|
||
|
||
class Voice(TypedDict): | ||
"""Voice data.""" | ||
|
||
Name: str | ||
ShortName: str | ||
Gender: Literal["Female", "Male"] | ||
Locale: str | ||
SuggestedCodec: Literal["audio-24khz-48kbitrate-mono-mp3"] | ||
FriendlyName: str | ||
Status: Literal["GA"] | ||
VoiceTag: VoiceTag | ||
|
||
|
||
class VoiceManagerVoice(Voice): | ||
"""Voice data for VoiceManager.""" | ||
|
||
Language: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters