Skip to content

Commit

Permalink
[Fix] Delete superfluous code
Browse files Browse the repository at this point in the history
  • Loading branch information
suxinde2009 committed Dec 14, 2023
1 parent 4d0fdf8 commit 8d6cea3
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/edge_tts/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,11 @@ async def _print_voices(*, proxy: str) -> None:
print(f"{pretty_key_name}: {voice[key]}")


def spinoff_sentence(sentence):
def _spinoff_sentence(sentence):
last_word = sentence[-1]
last_word_num = sentence.count(last_word)
return (sentence, last_word, last_word_num)

async def tts_subtitle(text, three_dimensional_list, voice, audio_path, subtitle_path):
communicate = edge_tts.Communicate(text, voice)
submaker = edge_tts.SubMaker()
with open(audio_path, "wb") as file:
async for chunk in communicate.stream():
if chunk["type"] == "audio":
file.write(chunk["data"])
elif chunk["type"] == "WordBoundary":
submaker.create_sub((chunk["offset"], chunk["duration"]), chunk["text"])
with open(subtitle_path, "w", encoding="utf-8") as file:
file.write(submaker.generate_subs(three_dimensional_list=three_dimensional_list))

async def _run_tts(args: Any) -> None:
"""Run TTS after parsing arguments from command line."""

Expand Down Expand Up @@ -85,7 +73,7 @@ async def _run_tts(args: Any) -> None:
sentences = [sentence.strip() for sentence in sentences if sentence.strip()]
three_dimensional_list = []
for sentence in sentences:
three_dimensional_list.append(spinoff_sentence(sentence))
three_dimensional_list.append(_spinoff_sentence(sentence))

with open(
args.write_media, "wb"
Expand Down

0 comments on commit 8d6cea3

Please sign in to comment.