Here is the revised README.md for your LLMTTS project, strictly professional and without emojis:
LLMTTS is a Python-based real-time system that streams responses from a Large Language Model (LLM) and converts them into speech using Microsoft Edge TTS and pygame. It supports Thai and English, streaming text generation, dynamic audio buffering, and voice fallback.
- Real-time text generation and audio playback
- Seamless voice fallback mechanism across multiple TTS voices
- Thai language support with optional tokenization
- Text-to-speech conversion using Microsoft Edge neural voices
- Integration with OpenTyphoon LLM via OpenAI-compatible API
- Sends a user prompt to the OpenTyphoon LLM.
- Streams generated text token by token.
- Buffers text until a sentence is complete or a threshold is reached.
- Converts buffered text to audio using
edge-tts. - Plays audio in real-time using
pygamewhile streaming continues.
Install the dependencies with:
pip install openai edge-tts pygame thai-tokenizerAdditional system requirement: ffmpeg must be installed and available in your system path for edge-tts to function.
Set the environment variable for your API key:
os.environ["OPENAI_API_KEY"] = "<your-api-key>"Make sure to point to the correct base URL if using a custom or third-party LLM service:
base_url="https://api.opentyphoon.ai/v1"The system uses the following Microsoft neural voices (in priority order):
th-TH-NiwatNeuralth-TH-PremwadeeNeuralen-US-ChristopherNeural
It will attempt fallback in this order if a voice fails during audio generation.
LLMTTS/
├── llmtts.py # Main application script
├── requirements.txt # Optional, list of dependencies
└── README.md # Documentation
messages = [
{
"role": "user",
"content": "วันนี้กินข้าวกับอะไรดี"
}
]The model responds in real-time, and the audio is generated and played sentence-by-sentence.
- The
Tokenizerfromthai_tokenizeris initialized for future use in sentence segmentation or domain-specific parsing. - The queue-based design ensures audio playback does not block streaming or processing.
- This script is suitable for voice assistants, chatbots, or language learning tools.