A minimal Node.js server that provides AI conversation capabilities with Text-to-Speech (TTS) support for Tencent Real-Time Communication (TRTC).
- 🎙️ Real-time AI conversation with voice support
- 🤖 Integrated LLM for intelligent responses
- 🔊 Text-to-Speech using MiniMax TTS
- 🌐 Web-based conversation interface
- 🚀 Simple single-file backend architecture
- Node.js (v14.0.0 or higher)
- Tencent Cloud account with TRTC enabled
- LLM API access (OpenAI compatible)
- MiniMax TTS API access
- Clone the repository:
git clone https://github.com/yourusername/trtc-ai-tts.git
cd trtc-ai-tts- Install dependencies:
npm install- Configure environment variables:
cp env.example .env
# Edit .env with your credentials- Start the server:
npm start- Open your browser and navigate to:
http://localhost:3000/conversation.html
Create a .env file with the following variables:
# Tencent Cloud API
TENCENT_SECRET_ID=your_secret_id
TENCENT_SECRET_KEY=your_secret_key
TENCENT_REGION=ap-guangzhou
TENCENT_ENDPOINT=trtc.tencentcloudapi.com
# TRTC Configuration
TRTC_SDK_APP_ID=your_sdk_app_id
TRTC_SECRET_KEY=your_trtc_secret_key
# LLM Configuration
LLM_API_URL=your_llm_api_url
LLM_API_KEY=your_llm_api_key
LLM_MODEL=your_model_name
# MiniMax TTS
MINIMAX_TTS_GROUP_ID=your_group_id
MINIMAX_TTS_API_KEY=your_api_key
MINIMAX_TTS_VOICE_TYPE=your_voice_type
MINIMAX_TTS_API_URL=http://api.minimax.chat/v1/t2a_v2
MINIMAX_TTS_MODEL=speech-01-turbo| Method | Endpoint | Description |
|---|---|---|
| POST | /conversations |
Start a new AI conversation |
| DELETE | /conversations |
Stop an active conversation |
| POST | /credentials |
Generate TRTC user credentials |
trtc-ai-tts/
├── server.js # Main server file with all backend logic
├── conversation.html # Web interface for conversations
├── package.json # Dependencies and scripts
├── .env # Environment variables (not committed)
└── .gitignore # Git ignore rules
- Start a conversation: Click "Start Chat" in the web interface
- Speak or type: The AI will respond with both text and voice
- Interrupt: Use the interrupt button to stop the AI mid-response
- End conversation: Click "End Chat" to terminate the session
Run in development mode with auto-reload:
npm run devexpress- Web frameworkcors- CORS middlewaredotenv- Environment variable managementtencentcloud-sdk-nodejs-trtc- Tencent Cloud TRTC SDKtls-sig-api-v2- TRTC signature generationmorgan- HTTP request logger
MIT
For issues and questions, please create an issue in the GitHub repository.