Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions src/edge_tts/communicate.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,26 +311,6 @@ def ssml_headers_plus_data(request_id: str, timestamp: str, ssml: str) -> str:
)


def calc_max_mesg_size(tts_config: TTSConfig) -> int:
"""Calculates the maximum message size for the given voice, rate, and volume.

Returns:
int: The maximum message size.
"""
websocket_max_size: int = 2**16
overhead_per_message: int = (
len(
ssml_headers_plus_data(
connect_id(),
date_to_string(),
mkssml(tts_config, ""),
)
)
+ 50 # margin of error
)
return websocket_max_size - overhead_per_message


class CommunicateRequest(TypedDict):
"""
A class to communicate with the service.
Expand Down Expand Up @@ -379,7 +359,7 @@ def __init__(
# Split the text into multiple strings and store them.
self.texts = split_text_by_byte_length(
escape(remove_incompatible_characters(text)),
calc_max_mesg_size(self.tts_config),
4096,
)

# Validate the proxy parameter.
Expand Down
2 changes: 1 addition & 1 deletion src/edge_tts/srt_composer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A tiny library for composing SRT files.

Based on https://github.com/cdown/srt with parsing, subtitle modifying,
Based on https://github.com/cdown/srt with parsing, subtitle modifying
functionality and Python 2 support removed. This is because of
https://github.com/rany2/edge-tts/issues/383.

Expand Down
Loading