Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Add Turn Taking & Time Limits to a Voice Interview Bot

· 4 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

This guide shows you how to add turn-taking interruptions and time limits to a voice interview bot, so conversations feel natural and stay on schedule. You'll configure the bot to interrupt long-winded answers, enforce per-question time caps, and handle speaker overlap gracefully. Before starting, ensure you have access to your bot's dialogue management code (e.g., in Python, Node.js, or a platform like Dialogflow) and a way to test voice input/output.

What You'll Need

  • A working voice interview bot with basic question-answer flow
  • Access to the codebase or configuration files (e.g., Python, Node.js, or a voice platform)
  • A voice activity detection (VAD) library or built-in feature (e.g., WebRTC VAD, Silero VAD)
  • A text-to-speech (TTS) and speech-to-text (STT) service (e.g., Google Cloud Speech, Azure Speech, or open-source like Whisper)
  • Ability to run and test the bot locally or in a staging environment

Step-by-Step

  1. Define turn-taking rules. Decide when the bot can interrupt. Common rules: after a pause longer than 1.5 seconds, if the user speaks for more than 30 seconds, or if the user says a keyword like "next question." Write these as clear conditions in your code.
  2. Implement voice activity detection (VAD). Integrate a VAD library to detect when the user is speaking and when they pause. For example, in Python you can use webrtcvad or silero-vad. Feed the audio stream into the VAD and get a status: speaking or not speaking.
  3. Track speaking duration. When VAD says the user is speaking, start a timer. If the timer exceeds your max answer length (e.g., 30 seconds), trigger an interruption. Reset the timer when the user stops speaking.
  4. Implement interruption logic. When an interruption is triggered, stop the user's audio capture (or mute it), play a short beep or say "Let me stop you there," then move to the next question or a follow-up. Ensure the bot's TTS can speak over the user's audio if needed, or simply pause the user's input.
  5. Add per-question time limits. Set a global timer for each question (e.g., 60 seconds). When the timer expires, the bot should prompt the user to wrap up or move on. Use a countdown that starts when the question is asked.
  6. Handle overlapping speech. If the user and bot speak at the same time, decide who yields. Typically, the bot should stop speaking if the user starts talking (barge-in). Implement barge-in by detecting user speech while TTS is playing and immediately stopping TTS.
  7. Test with simulated users. Write a test script that simulates a user speaking for a long time, pausing, and interrupting. Verify the bot's behavior matches your rules.
  8. Deploy and monitor. After testing, deploy the updated bot. Monitor logs for interruption frequency and timeouts to fine-tune thresholds.

Common Mistakes

  • Setting thresholds too low. A 1-second pause might trigger interruptions during normal thinking. Use 1.5-2 seconds.
  • Ignoring background noise. VAD may treat noise as speech. Use noise suppression and set a confidence threshold.
  • Not handling barge-in. If the bot keeps talking while the user tries to answer, it feels broken. Always allow barge-in.
  • Time limits starting too early. The timer should start after the bot finishes asking the question, not during the question.
  • Forgetting to reset timers. If a user pauses and resumes, reset the speaking timer to avoid premature interruption.

Tips

  • Use a small pause threshold (e.g., 0.5s) to detect the end of a user's turn, but a larger one (1.5s) to decide when to interrupt.
  • Make interruptions polite: "I want to make sure we cover everything, let's move to the next question."
  • Log every interruption and timeout with timestamps to identify questions that consistently run over.
  • Consider a grace period of 2-3 seconds after the time limit before interrupting, to avoid cutting off a natural conclusion.
  • Test with different accents and speaking speeds to ensure VAD works reliably.

Troubleshooting

  • Bot interrupts too often. Increase the pause threshold or the max speaking duration. Also check if VAD is misclassifying silence as speech.
  • Bot never interrupts. Verify that the VAD is correctly detecting speech. Print debug logs of VAD status and timers.
  • Time limits not firing. Ensure the timer is started in the correct callback (after question is spoken). Check if the timer is being reset unintentionally.
  • Barge-in not working. Confirm that TTS can be stopped mid-stream. Some TTS services require a specific API call to stop playback.
  • Audio cuts out. If interrupting causes audio glitches, add a small fade-out or delay before stopping.

Frequently Asked Questions

What is a good max answer length?

For most interviews, 30-45 seconds per answer is reasonable. Adjust based on question complexity.

Can I let the user finish their sentence before interrupting?

Yes, use a short grace period (1-2 seconds) after the time limit before interrupting, to avoid cutting off mid-word.

How do I handle a user who keeps talking over the bot?

Allow barge-in so the bot stops speaking. If the user continues, you can re-ask the question or move on after a few attempts.

Does this work with any voice platform?

The concepts are universal. Implementation details vary, but most platforms (e.g., Alexa, Dialogflow, custom apps) support VAD and TTS control.

What if the user is silent for a long time?

Set a no-response timeout (e.g., 10 seconds) to prompt the user or move to the next question.

Can I make the bot's interruption sound more natural?

Use a short filler like "Excuse me" or "Let me jump in" before the interruption. Also vary the phrasing to avoid sounding robotic.