Skip to content

chicogong/trtc-ai-tts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TRTC AI TTS Service

A minimal Node.js server that provides AI conversation capabilities with Text-to-Speech (TTS) support for Tencent Real-Time Communication (TRTC).

Features

  • 🎙️ 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

Quick Start

Prerequisites

  • Node.js (v14.0.0 or higher)
  • Tencent Cloud account with TRTC enabled
  • LLM API access (OpenAI compatible)
  • MiniMax TTS API access

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/trtc-ai-tts.git
cd trtc-ai-tts
  1. Install dependencies:
npm install
  1. Configure environment variables:
cp env.example .env
# Edit .env with your credentials
  1. Start the server:
npm start
  1. Open your browser and navigate to:
http://localhost:3000/conversation.html

Configuration

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

API Endpoints

Method Endpoint Description
POST /conversations Start a new AI conversation
DELETE /conversations Stop an active conversation
POST /credentials Generate TRTC user credentials

Project Structure

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

Usage

  1. Start a conversation: Click "Start Chat" in the web interface
  2. Speak or type: The AI will respond with both text and voice
  3. Interrupt: Use the interrupt button to stop the AI mid-response
  4. End conversation: Click "End Chat" to terminate the session

Development

Run in development mode with auto-reload:

npm run dev

Dependencies

  • express - Web framework
  • cors - CORS middleware
  • dotenv - Environment variable management
  • tencentcloud-sdk-nodejs-trtc - Tencent Cloud TRTC SDK
  • tls-sig-api-v2 - TRTC signature generation
  • morgan - HTTP request logger

License

MIT

Support

For issues and questions, please create an issue in the GitHub repository.

About

TRTC-AI Service TTS Demo Experience

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors