python

python 텍스트 문서 음성변환

bumychoi 2025. 5. 13. 10:09

import edge_tts
import asyncio

async def tts():
    # 텍스트 파일 읽기
    with open("2025_5_12.txt", "r", encoding="utf-8") as f:
        text = f.read()

    # 음성 설정: 남성 음성 (en-US-GuyNeural 등)
    communicate = edge_tts.Communicate(
        text=text,
        voice="ko-KR-InJoonNeural",  # 한국어 남성 음성
        rate="+0%"  # 속도 조절: +10%, -10% 등 가능
    )

    await communicate.save("output_edge.wav")
    print("자연스러운 음성 파일 생성 완료: output_edge.wav")

asyncio.run(tts())