Coding Challenge 188: Voice Chatbot @TheCodingTrain
Coding Challenge 188: Voice Chatbot  @TheCodingTrain
Uploaded April 2026 | Updated September 2026, 1 week ago
In this coding challenge, I build a conversational voice chatbot entirely in the browser with p5.js. I combine three pieces: speech-to-text with OpenAI's Whisper model, text-to-speech with Kokoro TTS, and a "brain" for the bot. I also explore the transformers.js pipeline API and the Web Audio API. For the bot's brain, I start with a simple ELIZA-style therapist, then incorporate a RiveScript number-guessing game, and finally a local LLM. Code: thecodingtrain.com/challenges/188-voice-chatbot

πŸš€ Watch this video ad-free on Nebula nebula.tv/videos/codingtrain-coding-challenge-188-voice-chatbot

p5.js Web Editor Sketches:
πŸ•ΉοΈ LLM Chatbot: editor.p5js.org/codingtrain/sketches/RHhT9I4Nm
πŸ•ΉοΈ Number Guessing Bot: editor.p5js.org/codingtrain/sketches/AJw7zMN9q
πŸ•ΉοΈ Therapy Bot: editor.p5js.org/codingtrain/sketches/37LFEPUVV
πŸ•ΉοΈ Model Loading Bars: editor.p5js.org/codingtrain/sketches/E9Ob3x8eJ
πŸ•ΉοΈ Waveform of Recording: editor.p5js.org/codingtrain/sketches/cck49wDub
πŸ•ΉοΈ Real Time Waveform: editor.p5js.org/codingtrain/sketches/aaRIT-x6a

πŸŽ₯ Previous: youtu.be/g3-PXyF8U70?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ All: youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH

References:
πŸ““ p5.2 Reference: beta.p5js.org
πŸ““ Introducing Whisper: cdn.openai.com/papers/whisper.pdf
πŸ““ Model Cards for Model Reporting: arxiv.org/abs/1810.03993
πŸ““ Open Neural Network Exchange: onnx.ai
πŸ““ Onnx-community Whisper-tiny.en model: huggingface.co/onnx-community/whisper-tiny.en
πŸ““ Xenova: github.com/xenova
πŸ““ Transformers.js: huggingface.co/docs/transformers.js/installation
πŸ““ Announcing the new p5.sound.js library!: medium.com/processing-foundation/announcing-the-new-p5-sound-js-library-42efc154bed0
πŸ““ getUserMedia() documentation: developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
πŸ““ MediaRecorder() documentation: developer.mozilla.org/en-US/docs/Web/API/MediaRecorder
πŸ““ Kokoro Repo: github.com/hexgrad/kokoro
πŸ““ KokoroTTS Model: huggingface.co/hexgrad/Kokoro-82M
πŸ““ ELIZA: en.wikipedia.org/wiki/ELIZA
πŸ““ Rivescript: rivescript.com
πŸ““ SmolLM3: huggingface.co/HuggingFaceTB/SmolLM3-3B
πŸ““ Running models on WebGPU: huggingface.co/docs/transformers.js/guides/webgpu
πŸ““ Using quantized models (dtypes): huggingface.co/docs/transformers.js/v3.8.1/guides/dtypes

Videos:
πŸš‚ youtu.be/0Ad5Frf8NBM
πŸš‚ youtu.be/KR61bXsPlLU

Live Stream Archives:
πŸ”΄ youtube.com/watch?v=KRDJAHArqaw

Related Coding Challenges:
πŸš‚ youtu.be/eGFJ8vugIWA
πŸš‚ youtu.be/8Z9FRiW2Jlc
πŸš‚ youtu.be/iFTgphKCP9U

Timestamps:
0:00:00 Hello!
0:00:35 Mapping out the pieces: speech-to-text, text-to-speech, and the brain
0:01:07 Thoughts on AI and creative exploration
0:02:44 Choosing the tools: Whisper and Kokoro TTS
0:04:06 Building a push-to-talk UI in p5.js
0:04:51 Finding models on Hugging Face with Transformers.js
0:05:36 About the Whisper model and model cards
0:06:55 Loading the Whisper pipeline in p5.js
0:09:04 Accessing the microphone with getUserMedia
0:10:44 Capturing audio with MediaRecorder
0:12:05 Processing audio chunks into a waveform
0:15:55 Speech-to-text working!
0:16:36 Building the chatbot brain (ELIZA-style therapist)
0:18:50 Setting up Kokoro TTS for text-to-speech
0:21:07 Playing synthesized audio with AudioBufferSource
0:23:41 Text-to-speech working!
0:25:32 Handling playback events
0:26:56 Swapping in a RiveScript number-guessing brain
0:31:22 Adding a language model (SmolLM2) as the brain
0:38:33 Final demo: the random number chatbot
0:39:03 Goodbye!

Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound

πŸš‚ Website: thecodingtrain.com
πŸ‘Ύ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
🚩 Suggest Topics: github.com/CodingTrain/Suggestion-Box
πŸ’‘ GitHub: github.com/CodingTrain
πŸ’¬ Discord: thecodingtrain.com/discord
πŸ’– Membership: youtube.com/thecodingtrain/join
πŸ›’ Store: standard.tv/codingtrain
πŸ–‹οΈ Twitter: twitter.com/thecodingtrain
πŸ“Έ Instagram: instagram.com/the.coding.train

πŸŽ₯ youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH
πŸŽ₯ youtube.com/playlist?list=PLRqwX-V7Uu6Zy51Q-x9tMWIv9cueOFTFA

πŸ”— p5.js: p5js.org
πŸ”— p5.js Web Editor: editor.p5js.org
πŸ”— Processing: processing.org

πŸ“„ Code of Conduct: github.com/CodingTrain/Code-of-Conduct

This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/new

#texttospeech #speechtotext #chatbot #rivescript #llms #agents #ai #transformersjs #webaudioapi #javascript #p5js
Coding Challenge 188: Voice ChatbotStickers!4.1: Particle System Simulation - The Nature of CodeCoding Train 2022 in Review, Plans for 2023Why Language Models Surprise YouCoding Challenge #97: The Book of Pi - Part 1Coding Challenge #140: Pi Approximation with Leibniz SeriesCoding Challenge 165: Slide Puzzle5.5 Wander Steering Behavior - The Nature of CodeCoding Train Stickers 2023 Last Call!More Nature of Code Chapter 2, + 3D Fractals?Welcome (again) to the New Studio - Topics TBD
The Coding Train |

Coding Challenge 188: Voice Chatbot

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER