Skip to content

VoiceTest: a real-time voice-enabled Discord bot that streams speech to OpenAI GPT-4o and plays AI-driven voice responses.

License

Notifications You must be signed in to change notification settings

purinton/voicetest

Repository files navigation

Purinton Dev

@purinton/voicetest npm version license build status

VoiceTest is a voice-enabled Discord bot built with Node.js and Discord.js. It captures live speech from users in a voice channel, streams it to OpenAI's GPT-4o-mini realtime API for transcription and AI response, then plays back synthesized voice responses—all in real time.


Table of Contents

Features

  • Real-time voice-to-text transcription using OpenAI GPT-4o-mini realtime
  • AI-generated voice responses streamed back into Discord
  • High-quality audio encoding/decoding with @purinton/resampler and Prism-media
  • Modular command and event handler architecture via @purinton/discord
  • Multi-language/localized responses with built-in locale files
  • Graceful startup, shutdown, and error handling via @purinton/common
  • Ready for Docker and systemd deployment
  • Comprehensive Jest test suite covering locales, commands, and events

Getting Started

  1. Clone this repository and install dependencies:

    git clone https://github.com/purinton/voicetest.git
    cd voicetest
    npm install
  2. Copy and configure your environment variables and instructions:

    copy .env.example .env
    copy instructions.txt.example instructions.txt
    • Fill in DISCORD_TOKEN, GUILD_ID, VOICE_CHANNEL_ID, and OPENAI_API_KEY in .env.
    • Edit instructions.txt to include any custom instructions for the voice agent.
  3. Start the bot locally:

    npm start
    # or
    node voicetest.mjs

Configuration

All settings are managed via environment variables in .env. See .env.example for required and optional keys.

Usage

  1. Invite your bot to a Discord server with the correct permissions.
  2. Join the configured voice channel.
  3. Speak into the channel—VoiceTest will transcribe your speech, send it to the AI, and play back the AI’s response automatically.

Customization

Commands

  • Add new commands by placing a .json definition and .mjs handler in the commands/ directory.

Events

  • Add or modify event handlers in the events/ directory. Handlers follow the Discord Gateway event names.

Locales

  • Update or add locale files in the locales/ directory. All responses and command metadata can be localized.

Deployment

Docker

Build and run with Docker:

docker build -t voicetest .
docker run --env-file .env voicetest

Systemd

  1. Copy voicetest.service to /etc/systemd/system/voicetest.service.

  2. Edit paths and user/group settings in the service file.

  3. Reload and start:

    sudo systemctl daemon-reload
    sudo systemctl enable voicetest
    sudo systemctl start voicetest

Testing

Run the full test suite:

npm test

Support

For questions or feedback, join the Purinton Dev Discord.

License

MIT © 2025 Russell Purinton

Links

About

VoiceTest: a real-time voice-enabled Discord bot that streams speech to OpenAI GPT-4o and plays AI-driven voice responses.

Topics

Resources

License

Stars

Watchers

Forks