Skip to content

Commit

Permalink
Cleanup parse_metadata
Browse files Browse the repository at this point in the history
Signed-off-by: rany2 <[email protected]>
  • Loading branch information
rany2 committed Feb 16, 2024
1 parent ec91ec1 commit e58af9d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/edge_tts/communicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ async def send_ssml_request() -> bool:
)
return True

def parse_metadata():
def parse_metadata() -> Dict[str, Any]:
for meta_obj in json.loads(data)["Metadata"]:
meta_type = meta_obj["Type"]
if meta_type == "WordBoundary":
Expand All @@ -365,10 +365,10 @@ def parse_metadata():
"duration": current_duration,
"text": meta_obj["Data"]["text"]["Text"],
}
elif meta_type in ("SessionEnd",):
if meta_type in ("SessionEnd",):
continue
else:
raise UnknownResponse(f"Unknown metadata type: {meta_type}")
raise UnknownResponse(f"Unknown metadata type: {meta_type}")
raise UnexpectedResponse("No WordBoundary metadata found")

# Split the text into multiple strings if it is too long for the service.
texts = split_text_by_byte_length(
Expand Down

0 comments on commit e58af9d

Please sign in to comment.