Skip to content

laolin5564/discord-voice-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎙️ Discord Voice Bot

Real-time AI voice chat in Discord voice channels. Talk to an AI assistant like a phone call.

[中文] Discord 语音频道 AI 实时语音对话机器人,像打电话一样和 AI 聊天。

How It Works / 工作原理

User speaks → Discord PCM audio → Silence detection → Whisper STT
                                                         ↓
                                                   LLM generates reply
                                                         ↓
Play audio  ←  FFmpeg decode  ←  Edge-TTS synthesis  ←  AI text reply

Features / 功能特性

  • 🎤 Real-time Voice Chat — Speak naturally in Discord voice channels
  • 🧠 LLM-powered Responses — Uses any OpenAI-compatible API
  • 🗣️ Whisper STT — Local speech-to-text with OpenAI Whisper
  • 🔊 Edge-TTS — High-quality text-to-speech with Microsoft Edge voices
  • 🔇 Silence Detection — Automatically detects when you stop talking

Quick Start / 快速开始

Prerequisites

  • Python 3.10+
  • FFmpeg installed
  • A separate Discord Bot Token (cannot share with other bots)

Setup

# Install dependencies
pip install -r requirements.txt

# Configure
cp .env.example .env
# Edit .env with your bot token and API keys

# Run
python bot.py

Discord Bot Setup

  1. Go to Discord Developer Portal
  2. Create New Application
  3. Go to Bot → Copy Token, enable Message Content Intent
  4. OAuth2URL Generator: Scopes: bot, Permissions: Connect, Speak, Use Voice Activity, Send Messages
  5. Invite bot to your server with the generated URL

⚠️ Important: You need a dedicated bot token. Discord only allows one Gateway connection per token.

Tech Stack / 技术栈

  • Language: Python
  • STT: OpenAI Whisper (local)
  • TTS: edge-tts (Microsoft Edge voices)
  • LLM: Any OpenAI-compatible API
  • Audio: FFmpeg, discord.py voice

Configuration / 配置

Variable Description
DISCORD_TOKEN Bot token (dedicated, not shared)
GUILD_ID Discord server ID
AI_BASE_URL OpenAI-compatible API endpoint
AI_API_KEY API key for LLM
AI_MODEL Model name
WHISPER_MODEL Whisper model size (tiny/base/small/medium/large)
TTS_VOICE Edge-TTS voice name
SYSTEM_PROMPT AI personality prompt

Contributing / 贡献

PRs welcome! Please test with a real Discord voice channel before submitting.

License / 许可证

MIT License

About

Real-time AI voice chat bot for Discord | Discord 语音频道 AI 实时对话机器人

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors