DiscordNPC lets you interact with ChatGPT through a Discord voice channel, enabling a natural conversation.
Entirely stateless, and the bot will start a new conversation when it is removed from the call and placed back in.
It also includes a simple Discord command for asking questions.
Powered by google-speech
, acheong08/ChatGPT
, and py-cord
.
There are many sources of latency, mainly the ChatGPT "API" and the AssemblyAI real-time transcription API. This leads to some long waiting times, but it works.
Additionally, ChatGPT has very low rate limits and will return a 429 error if you send too many requests. This is not handled by the bot, so you will have to wait for the rate limit to reset.
I implemented a rate limiter in the bot, but it is not very effective. It just says "I lost my train of thought. Give me a minute to get back on track..." right now.
All manual baby! This project is a proof of content and does not currently include a Dockerfile.
Install with poetry install --no-root --without dev
and you will be good to go.
Some project dependencies have native dependencies:
- SoX
- Debian package:
sox
- MacOS brew:
brew install sox
- Windows download: https://sourceforge.net/projects/sox/files/sox/14.4.2/
- Debian package:
- SoX MP3 Support
- Debian package:
libsox-fmt-mp3
- MacOS brew:
brew install sox --with-lame
- It is hard to find Windows DLLs, so I included a
/bin
folder in the repository with the DLLs I found to work.
- Debian package:
ffmpeg
CHATGPT_*
: Configuration foracheong08/ChatGPT
. Arguments are analogous to the config.json format defined in this wiki page for the ChatGPT python wrapper.- i.e.:
CHATGPT_SESSION_TOKEN
is analogous tosession_token
in the config.json file.
- i.e.:
DNPC_TOKEN
: Discord bot token. Can be created in the Discord Developer Portal.DNPC_WEBHOOK
: Discord webhook to log with. Designed for "production" use, not required.DNPC_ASSEMBLY_TOKEN
: AssemblyAI token for speech-to-text. Required for speech-to-text functionality. Can be obtained on the app dashboard.- You'll need to have a paid account to use the real-time transcription.
- If you know an alternative to AssemblyAI that is free, tell me on Discord:
@regulad#7959
After setting the required environment variables, run poetry run python -m discordnpc
to start the bot.
DiscordNPC provides 2 Discord slash commands:
/ask
: Ask a simple question to ChatGPT./join
: Start a conversation in the voice channel you are currently connected to.