파이썬 EdgeTTS 동영상 영어 단어장 (2차) - 3개 이상 단어 있는 경우
오쌤_oSam
2025.01.14

소개
파이썬 EdgeTTS 라이브러리를 통해 영어 단어장을 만들었는데
카나다에서 의학 공부를 하면서 모르는 단어를 공부하기 위해 단어작을 작성했는데, 영어 강의 내용을 정리하다 보니 단어가 2개 이상에서 5개가 넘는 경우가 발생했고,
기존 단어장은 한단어 위주로 한 것이라서 3단어 이상인 경우 단어가 화면에 다 표시되지 않고
영어 단어를 다 읽기 전에 한글 단어를 읽는 문제가 발생
진행 방법
어떤 도구를 사용했고, 어떻게 활용하셨나요?
Cursor 파이썬 입코딩
Tip: 사용한 프롬프트 전문을 꼭 포함하고, 내용을 짧게 소개해 주세요.
Tip: 활용 이미지나 캡처 화면을 꼭 남겨주세요.

Tip: 코드 전문은 코드블록에 감싸서 작성해주세요. ( / 을 눌러 '코드 블록'을 선택)
1차 수정했으나 영어 단어가 5개를 넘어갈 경우
아직 다 표시되지 않는 문제가 있어서 재차 요청

def update_display(self, current_word, next_word=None, total_time=None):
"""화면 업데이트"""
current_index = self.words.index(current_word)
self.progress_label.config(text=f"진행: {current_index + 1}/{self.total_words}")
if total_time is not None:
self.time_label.config(text=f"경과 시간: {format_time(total_time)}")
self.number_label.config(text=f"{current_word[2]}번")
# 단어/구문 길이에 따른 글자 크기 동적 조정
word_length = len(current_word[0])
if word_length > 50:
font_size = 54
elif word_length > 40:
font_size = 60
elif word_length > 30:
font_size = 70
elif word_length > 20:
font_size = 80
else:
font_size = 100
# 긴 문장의 경우 자동 줄바꿈 처리
words = current_word[0].split()
lines = []
current_line = []
for word in words:
current_line.append(word)
# 한 줄에 약 4개 단어가 들어가도록 조정 (더 큰 글자를 위해)
if len(current_line) >= 4:
lines.append(' '.join(current_line))
current_line = []
if current_line: # 마지막 줄 처리
lines.append(' '.join(current_line))
# 줄바꿈으로 연결하여 표시
formatted_text = '\n'.join(lines)
self.word_label.config(
text=formatted_text,
font=("Helvetica", font_size, "bold"),
wraplength=1100 # 창 너비에 맞게 조정
)
# 의미도 같은 방식으로 처리
meaning_length = len(current_word[1])
if meaning_length > 40:
meaning_font_size = 70
else:
meaning_font_size = 80
self.meaning_label.config(
text=current_word[1],
font=("Helvetica", meaning_font_size, "bold"),
wraplength=1100
)
if next_word:
self.next_label.config(
text=f"다음: {next_word[0]}",
wraplength=1100
)
else:
self.next_label.config(text="")결과와 배운 점
배운 점과 나만의 꿀팁을 알려주세요.
과정 중에 어떤 시행착오를 겪었나요?
변화된 상황이 있으면 그 내용을 객관적으로 분명하게 설명하고 해결 방법을 요청
영어 단어 수에 따라 단계적으로 영어 폰트를 동적으로 조정 가능
영어 문장중에 '/'를 슬래시로 읽는 것을 읽지 않게 요청
도움이 필요한 부분이 있나요?
앞으로의 계획이 있다면 들려주세요.
1개 단어로 된 단어장에서 출발, 여러 단어인 경우까지 발전했고
영어 회화 문장인 경우에도 적용
도움 받은 글 (옵션)
참고한 지피터스 글이나 외부 사례를 알려주세요.
(내용 입력)
