mirror of
https://github.com/rany2/edge-tts
synced 2024-11-22 01:45:02 +00:00
Fix "ValueError: the metadata doesn't contain a Duration field"
* seems like microsoft updated their API to include this metadata type Fixes #16
This commit is contained in:
parent
68a9e191d7
commit
3a4595d6d6
@ -1,6 +1,6 @@
|
||||
[metadata]
|
||||
name = edge-tts
|
||||
version = 5.0.0
|
||||
version = 5.0.1
|
||||
author = rany
|
||||
author_email = ranygh@riseup.net
|
||||
description = Microsoft Edge's TTS
|
||||
|
@ -333,19 +333,13 @@ class Communicate:
|
||||
metadata_offset = metadata["Metadata"][0]["Data"][
|
||||
"Offset"
|
||||
]
|
||||
try:
|
||||
if metadata_type == "WordBoundary":
|
||||
metadata_duration = metadata["Metadata"][0]["Data"][
|
||||
"Duration"
|
||||
]
|
||||
except KeyError as exception:
|
||||
raise ValueError(
|
||||
"The metadata doesn't contain a Duration field. "
|
||||
+ "This usually happens when SentenceBoundary metadata type is sent."
|
||||
) from exception
|
||||
metadata_text = metadata["Metadata"][0]["Data"]["text"][
|
||||
"Text"
|
||||
]
|
||||
if metadata_type == "WordBoundary":
|
||||
metadata_text = metadata["Metadata"][0]["Data"]["text"][
|
||||
"Text"
|
||||
]
|
||||
yield (
|
||||
[
|
||||
metadata_offset,
|
||||
@ -358,6 +352,8 @@ class Communicate:
|
||||
raise NotImplementedError(
|
||||
"SentenceBoundary is not supported due to being broken."
|
||||
)
|
||||
elif metadata_type == "SessionEnd":
|
||||
continue
|
||||
else:
|
||||
raise NotImplementedError(
|
||||
f"Unknown metadata type: {metadata_type}"
|
||||
|
Loading…
Reference in New Issue
Block a user