vonage-python-sdk
vonage-python-sdk copied to clipboard
fix: change ncco websocket endpoint contentType to content-type
When using the NCCO builder to create a Websocket Connect Endpoint, it serializes to have a field 'contentType', whilst the API expects a field of 'content-type'
Expected Behavior
{ "content-type": "...." }
Current Behavior
{ "contentType": "...." }
Possible Solution
Code
# Where BITRATE=16, and FREQUENCY=16000
ws = ConnectEndpoints.WebsocketEndpoint(
uri=some_url,
contentType=f"audio/l{StreamingConfig.BITRATE};rate={StreamingConfig.FREQUENCY}"
)
c = Ncco.Connect(endpoint=ws, eventType="synchronous")
ncco = Ncco.build_ncco(c)
print(json.dumps(ncco, indent=4))
Response to Voice API
[
{
"action": "connect",
"endpoint": [
{
"type": "websocket",
"uri": "wss://***.ngrok-free.app/ws",
"contentType": "audio/l16;rate=8000"
}
],
"eventType": "synchronous"
}
]
Websocket Connected Message
{
"content-type": "audio/l16;rate=16000",
"event": "websocket:connected"
}
After Applying Fix
{
"content-type": "audio/l16;rate=8000",
"event": "websocket:connected"
}
Your Environment
- Version used: latest (bug can be seen in src)