1. 엑셀파일 csv파일 변환
엑셀파일 | csv파일 |
![]() |
![]() |
cvs파일로 저장 : 파일 > 다른이름으로 저장 > 파일형식 : csv(쉼표로 분리)지정 저장 | |
![]() |
1) 엑셀 파일에 단어 정리
: 1열 - 단어 / 2열 - 뜻
2) 엑셀파일을 csv파일로 저장 - 아래 실행파일과 동일 위치에 저장
2. 필요 모듈 설치
1) 명령프롬프트 실행 : 검색창 > cmd 검색 실행
2) gTTs(text읽기 모듈), pyglet(mp3실행 모듈) 설치
pip install gTTS
pip install pyglet
3. 실행 파일
from gtts import gTTS
from time import sleep
import os
import pyglet
def tts(source_text: str = 'hello', target_file_name: str = 'temp', language: str = 'en'):
tts = gTTS(text=source_text, lang=language) # 텍스트 -> 음성 객체 생성
filename = target_file_name + ".mp3"
tts.save(filename) # 음성 파일 저장
music = pyglet.media.load(filename, streaming=False) # gtts생성파일 로딩
music.play() # 음성파일 play
sleep(music.duration) # prevent from killing
os.remove(filename) # remove file
def word_feed(start_line: int = 0, repeat: int = 3, filename: str = r"C:\Users\neo21\Downloads\1111.csv") -> None:
f = open(filename, 'r')
lines = f.readlines()
i = 0
for l in lines:
i += 1
if i < start_line:
continue
else:
print(l)
sep = l.find(',')
word = l[:sep]
meaning = l[sep + 1:]
meaning_new = meaning.replace('~', '무슨무슨')
for k in range(repeat):
tts(word)
sleep(0.5)
tts(meaning_new, language='ko')
if __name__ == '__main__':
word_feed()
4. 실행
if __name__ == '__main__':
word_feed(start_line = 200, filename = r"C:\Users\neo21aq\test.csv")
word_fee() 인자 설명
start_line : 학습 시작 라인 지정 (미지정 시 처음부터 시작)
repeat : 영어 발음 반복횟수 지정 ( 미지정 시 3회 반복)
filename : csv파일 저장 위치 지정★★★
예) r"C:\Users\neo21aq\source\repos\src\test.csv"
"C:/Users/neo21aq/source/repos/src/test.csv"
5. 참조
https://fiasco-at-python.tistory.com/13
gTTs 사용법
gTTs : https://gtts.readthedocs.io/en/latest/index.html# gTTS — gTTS documentation © Copyright 2014-2021 Pierre Nicolas Durette. Revision 3d6cfc9d. gtts.readthedocs.io pyglet : https://pypi.org/project/pyglet/ pyglet Cross-platform windowing and multime
fiasco-at-python.tistory.com
https://fiasco-at-python.tistory.com/12
google trans 사용법
공식 homepage : https://github.com/ssut/py-googletrans GitHub - ssut/py-googletrans: (unofficial) Googletrans: Free and Unlimited Google translate API for Python. Translates totally f (unofficial) Googletrans: Free and Unlimited Google translate API for
fiasco-at-python.tistory.com
6. 추가 작업
곰오디오등으로 실행 과정을 mp3로 녹화 하라!!!
pyQ로 visual화 하라!!!