Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.63k stars 2.84k forks source link

[azure-communication-callautomation] Streaming back data via WebSocket not working, can't hear my voice repeated back in the call. #37766

Open tan-phung-ts opened 1 month ago

tan-phung-ts commented 1 month ago

Describe the bug When using MediaStreamingOptions with custom transport_url to create a new call, then receive audio data and send it back immediately, no audio can be heard. I cannot seem to find any documentation talking about sending WebSocket data back to Azure.

To Reproduce Steps to reproduce the behavior:

  1. Create a new call

        media_streaming_options = MediaStreamingOptions(
            transport_url=ws_base_url,
            transport_type=MediaStreamingTransportType.WEBSOCKET,
            content_type=MediaStreamingContentType.AUDIO,
            audio_channel_type=MediaStreamingAudioChannelType.MIXED,
            start_media_streaming=record,
        )
    
        call_conn_props: CallConnectionProperties = (
            await call_automation_client.create_call(
                target_participant=target,
                callback_url=AzureClientService._gen_events_callback_url(
                    base_url=base_url, call_id=call_id
                ),
                source_caller_id_number=source,
                media_streaming=media_streaming_options,
            )
        )
  2. Receive the WebSocket connection. Send back the data (The whole object), I've tried sending back only the data, too, and it still won't work
    @router.websocket("/connect_call/{id}/azure")
    async def connect_call_azure(id: str, websocket: WebSocket) -> None:
    await ws.accept()
    while True:
        try:
            message: str = await ws.receive_text()
            await ws.send_text(data=message)
        except Exception as e:
            logger.error(
                message=f"Unknown Exception:{e}\n traceback:{traceback.format_exc()}"
            )
            break

Expected behavior In the call, I can hear my voice back when I speak.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Any documentation discussing this feature when using create_call with MediaStreamingOptions, how to handle the WebSocket connection, the format, and the data specifications would be great. Thanks.

github-actions[bot] commented 1 month ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @minwoolee-msft.