twilio-python icon indicating copy to clipboard operation
twilio-python copied to clipboard

[BUG] barge_in Argument in <Gather> Verb Not Functioning

Open mbuser03 opened this issue 9 months ago • 1 comments

Describe the bug

Hello,

I'm trying to use the Gather verb in Twilio to allow users to interrupt a Say message by speaking. However, setting barge_in=True appears to have no effect — the Say message continues to play and is not interrupted by speech input.

Could you please help me resolve this issue?

Code snippet

# -*- coding: iso-8859-1 -*-
from fastapi import FastAPI, WebSocket,Response
from fastapi.responses import HTMLResponse
from twilio.twiml.voice_response import VoiceResponse, Start, Gather
import uvicorn

app = FastAPI()

@app.post("/incoming")
async def start():
    response = VoiceResponse()
    gather = Gather(
        input='speech',
        barge_in=True,  
        timeout=5
    )
    gather.say("Hallo, ich bin ein Assistent. Bitte gebe 1, 2 oder 3 ein. Hast du sonst noch wünsche?",language= "de-DE", voice= "Polly.Vicki-Neural")
    response.append(gather)
    print(response)
    return HTMLResponse(content=str(response), media_type="application/xml")

if __name__ == "__main__":
    uvicorn.run("Funktionierende_Lösung:app", host="0.0.0.0", port=5050, reload=True)

Actual behavior

The Say message continues to play and is not interrupted by speech input.

Expected behavior

The Say message should be interrupted by speech input and should stop to play.

twilio-python version

9.4.5

Python version

3.12

Logs or error messages

No response

Additional context

No response

mbuser03 avatar May 09 '25 13:05 mbuser03

Hi!

I’d like to work on this issue. I’m new to twilio-python, but I’m eager to learn and contribute. If there are any specific guidelines or resources you recommend for first-time contributors, please let me know.

Also, if you have any pointers on where to start investigating the barge_in behavior, I’d appreciate it.

Thanks!

AshAnand34 avatar Jun 20 '25 14:06 AshAnand34