Skip to content

Commit 5caf874

Browse files
author
Vinothini Dharmaraj
committed
addressing the azure comments
1 parent 8d69715 commit 5caf874

File tree

10 files changed

+214
-206
lines changed

10 files changed

+214
-206
lines changed

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from ._version import VERSION
99
from ._call_automation_client import CallAutomationClient
1010
from ._call_connection_client import CallConnectionClient
11-
from .streaming.streaming_data_parser import StreamingDataParser
11+
from ._streaming_data_parser import StreamingDataParser
1212
from ._models import (
1313
CallConnectionProperties,
1414
FileSource,

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_call_automation_client.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ def create_call(
178178
source_display_name: Optional[str] = None,
179179
operation_context: Optional[str] = None,
180180
cognitive_services_endpoint: Optional[str] = None,
181-
media_streaming_options: Optional['MediaStreamingOptions'] = None,
182-
transcription_options: Optional['TranscriptionOptions'] = None,
181+
media_streaming: Optional['MediaStreamingOptions'] = None,
182+
transcription: Optional['TranscriptionOptions'] = None,
183183
**kwargs
184184
) -> CallConnectionProperties:
185185
"""Create a call connection request to a target identity.
@@ -200,11 +200,11 @@ def create_call(
200200
:keyword cognitive_services_endpoint:
201201
The identifier of the Cognitive Service resource assigned to this call.
202202
:paramtype cognitive_services_endpoint: str or None
203-
:keyword media_streaming_options: Media Streaming Configuration.
204-
:paramtype media_streaming_options: ~azure.communication.callautomation.MediaStreamingOptions
203+
:keyword media_streaming: Media Streaming Configuration.
204+
:paramtype media_streaming: ~azure.communication.callautomation.MediaStreamingOptions
205205
or None
206-
:keyword transcription_options: Configuration of live transcription.
207-
:paramtype transcription_options: ~azure.communication.callautomation.TranscriptionOptions
206+
:keyword transcription: Configuration of live transcription.
207+
:paramtype transcription: ~azure.communication.callautomation.TranscriptionOptions
208208
or None
209209
:return: CallConnectionProperties
210210
:rtype: ~azure.communication.callautomation.CallConnectionProperties
@@ -224,8 +224,8 @@ def create_call(
224224
targets = [serialize_identifier(p) for p in target_participant]
225225
except TypeError:
226226
targets = [serialize_identifier(target_participant)]
227-
media_config = media_streaming_options.to_generated() if media_streaming_options else None
228-
transcription_config = transcription_options.to_generated() if transcription_options else None
227+
media_config = media_streaming.to_generated() if media_streaming else None
228+
transcription_config = transcription.to_generated() if transcription else None
229229
create_call_request = CreateCallRequest(
230230
targets=targets,
231231
callback_uri=callback_url,
@@ -301,8 +301,8 @@ def answer_call(
301301
*,
302302
cognitive_services_endpoint: Optional[str] = None,
303303
operation_context: Optional[str] = None,
304-
media_streaming_options: Optional['MediaStreamingOptions'] = None,
305-
transcription_options: Optional['TranscriptionOptions'] = None,
304+
media_streaming: Optional['MediaStreamingOptions'] = None,
305+
transcription: Optional['TranscriptionOptions'] = None,
306306
**kwargs
307307
) -> CallConnectionProperties:
308308
"""Answer incoming call with Azure Communication Service's IncomingCall event
@@ -318,10 +318,10 @@ def answer_call(
318318
:paramtype cognitive_services_endpoint: str
319319
:keyword operation_context: The operation context.
320320
:paramtype operation_context: str
321-
:keyword media_streaming_options: Media Streaming Configuration.
322-
:paramtype media_streaming_options: ~azure.communication.callautomation.MediaStreamingOptions
323-
:keyword transcription_options: Configuration of live transcription.
324-
:paramtype transcription_options: ~azure.communication.callautomation.TranscriptionOptions
321+
:keyword media_streaming: Media Streaming Configuration.
322+
:paramtype media_streaming: ~azure.communication.callautomation.MediaStreamingOptions
323+
:keyword transcription: Configuration of live transcription.
324+
:paramtype transcription: ~azure.communication.callautomation.TranscriptionOptions
325325
or None
326326
:return: CallConnectionProperties
327327
:rtype: ~azure.communication.callautomation.CallConnectionProperties
@@ -337,10 +337,10 @@ def answer_call(
337337
call_intelligence_options=call_intelligence_options,
338338
answered_by=serialize_communication_user_identifier(
339339
self.source) if self.source else None,
340-
media_streaming_options=media_streaming_options.to_generated(
341-
) if media_streaming_options else None,
342-
transcription_options=transcription_options.to_generated()
343-
if transcription_options else None,
340+
media_streaming_options=media_streaming.to_generated(
341+
) if media_streaming else None,
342+
transcription_options=transcription.to_generated()
343+
if transcription else None,
344344
operation_context=operation_context
345345
)
346346

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_call_connection_client.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ def play_media(
421421
loop: bool = False,
422422
operation_context: Optional[str] = None,
423423
operation_callback_url: Optional[str] = None,
424+
interrupt_call_media_operation: bool = False,
424425
**kwargs
425426
) -> None:
426427
"""Play media to specific participant(s) in this call.
@@ -444,6 +445,9 @@ def play_media(
444445
This setup is per-action. If this is not set, the default callback URL set by
445446
CreateCall/AnswerCall will be used.
446447
:paramtype operation_callback_url: str or None
448+
:keyword interrupt_call_media_operation: If set play can barge into other existing
449+
queued-up/currently-processing requests. This is applicable only when play_to set to all.
450+
:paramtype interrupt_call_media_operation: bool
447451
:return: None
448452
:rtype: None
449453
:raises ~azure.core.exceptions.HttpResponseError:
@@ -454,6 +458,7 @@ def play_media(
454458
loop=loop,
455459
operation_context=operation_context,
456460
operation_callback_url=operation_callback_url,
461+
interrupt_call_media_operation=interrupt_call_media_operation,
457462
**kwargs
458463
)
459464

@@ -507,6 +512,7 @@ def _play_media(
507512
play_source_single = play_source
508513

509514
audience = [] if play_to == "all" else [serialize_identifier(i) for i in play_to]
515+
interrupt_call_media_operation = interrupt_call_media_operation if play_to == "all" else False
510516
play_request = PlayRequest(
511517
play_sources=[play_source_single._to_generated()] if play_source_single else # pylint:disable=protected-access
512518
[source._to_generated() for source in play_sources] if play_sources else None, # pylint:disable=protected-access
@@ -931,16 +937,17 @@ def stop_transcription(
931937
@distributed_trace
932938
def update_transcription(
933939
self,
940+
*,
934941
locale: str,
935942
speech_recognition_model_endpoint_id: Optional[str] = None,
936943
**kwargs
937944
) -> None:
938945
"""API to change transcription language.
939946
940-
:param locale: Defines new locale for transcription.
941-
:type locale: str
942-
:param speech_recognition_model_endpoint_id: Endpoint where the custom model was deployed.
943-
:type speech_recognition_model_endpoint_id: str
947+
:keyword locale: Defines new locale for transcription.
948+
:paramtype locale: str
949+
:keyword speech_recognition_model_endpoint_id: Endpoint where the custom model was deployed.
950+
:paramtype speech_recognition_model_endpoint_id: str
944951
:return: None
945952
:rtype: None
946953
:raises ~azure.core.exceptions.HttpResponseError:
@@ -1032,19 +1039,20 @@ def unhold(
10321039
@distributed_trace
10331040
def start_media_streaming(
10341041
self,
1042+
*,
10351043
operation_callback_url: Optional[str] = None,
10361044
operation_context: Optional[str] = None,
10371045
**kwargs
10381046
) -> None:
10391047
"""Starts media streaming in the call.
10401048
1041-
:param operation_callback_url: (Optional) Set a callback URL that overrides the default
1049+
:keyword operation_callback_url: (Optional) Set a callback URL that overrides the default
10421050
callback URL set by CreateCall/AnswerCall for this operation.
10431051
This setup is per-action. If this is not set, the default callback URL set by
10441052
CreateCall/AnswerCall will be used.
1045-
:type operation_callback_url: str or None
1046-
:param operation_context: (Optional) Value that can be used to track this call and its associated events.
1047-
:type operation_context: str or None
1053+
:paramtype operation_callback_url: str or None
1054+
:keyword operation_context: (Optional) Value that can be used to track this call and its associated events.
1055+
:paramtype operation_context: str or None
10481056
:return: None
10491057
:rtype: None
10501058
:raises ~azure.core.exceptions.HttpResponseError: If there's an HTTP response error.
@@ -1061,16 +1069,17 @@ def start_media_streaming(
10611069
@distributed_trace
10621070
def stop_media_streaming(
10631071
self,
1072+
*,
10641073
operation_callback_url: Optional[str] = None,
10651074
**kwargs
10661075
) -> None:
10671076
"""Stops media streaming in the call.
10681077
1069-
:param operation_callback_url: (Optional) Set a callback URL that overrides the default
1078+
:keyword operation_callback_url: (Optional) Set a callback URL that overrides the default
10701079
callback URL set by CreateCall/AnswerCall for this operation.
10711080
This setup is per-action. If this is not set, the default callback URL set by
10721081
CreateCall/AnswerCall will be used.
1073-
:type operation_callback_url: str or None
1082+
:paramtype operation_callback_url: str or None
10741083
:return: None
10751084
:rtype: None
10761085
:raises ~azure.core.exceptions.HttpResponseError: If there's an HTTP response error.

sdk/communication/azure-communication-callautomation/azure/communication/callautomation/_models.py

Lines changed: 137 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
# pylint: disable=too-many-lines
12
# -------------------------------------------------------------------------
23
# Copyright (c) Microsoft Corporation. All rights reserved.
34
# Licensed under the MIT License. See License.txt in the project root for
45
# license information.
56
# --------------------------------------------------------------------------
67
from typing import List, Optional, Union, TYPE_CHECKING
8+
from enum import Enum
79
from typing_extensions import Literal
810
from ._generated.models import (
911
CallLocator,
@@ -391,17 +393,17 @@ def _to_generated(self):
391393
class MediaStreamingOptions:
392394
"""Configuration of Media streaming.
393395
394-
:param transport_url: Transport URL for media streaming.
395-
:type transport_url: str
396-
:param transport_type: The type of transport to be used for media streaming.
397-
:type transport_type: str or ~azure.communication.callautomation.MediaStreamingTransportType
398-
:param content_type: Content type to stream, eg. audio, audio/video.
399-
:type content_type: str or ~azure.communication.callautomation.MediaStreamingContentType
400-
:param audio_channel_type: Audio channel type to stream, eg. unmixed audio, mixed audio.
401-
:type audio_channel_type: str or ~azure.communication.callautomation.MediaStreamingAudioChannelType
402-
:param start_media_streaming: Determines if the media streaming should be started immediately
396+
:keyword transport_url: Transport URL for media streaming.
397+
:paramtype transport_url: str
398+
:keyword transport_type: The type of transport to be used for media streaming.
399+
:paramtype transport_type: str or ~azure.communication.callautomation.MediaStreamingTransportType
400+
:keyword content_type: Content type to stream, eg. audio, audio/video.
401+
:paramtype content_type: str or ~azure.communication.callautomation.MediaStreamingContentType
402+
:keyword audio_channel_type: Audio channel type to stream, eg. unmixed audio, mixed audio.
403+
:paramtype audio_channel_type: str or ~azure.communication.callautomation.MediaStreamingAudioChannelType
404+
:keyword start_media_streaming: Determines if the media streaming should be started immediately
403405
after call is answered or not. Required.
404-
:type start_media_streaming: bool
406+
:paramtype start_media_streaming: bool
405407
"""
406408

407409
transport_url: str
@@ -418,6 +420,7 @@ class MediaStreamingOptions:
418420

419421
def __init__(
420422
self,
423+
*,
421424
transport_url: str,
422425
transport_type: Union[str, 'MediaStreamingTransportType'],
423426
content_type: Union[str, 'MediaStreamingContentType'],
@@ -442,20 +445,20 @@ def _to_generated(self):
442445
class TranscriptionOptions:
443446
"""Configuration of live transcription.
444447
445-
:param transport_url: Transport URL for live transcription. Required.
446-
:type transport_url: str
447-
:param transport_type: The type of transport to be used for live transcription, eg. Websocket.
448+
:keyword transport_url: Transport URL for live transcription. Required.
449+
:paramtype transport_url: str
450+
:keyword transport_type: The type of transport to be used for live transcription, eg. Websocket.
448451
Required. "websocket"
449-
:type transport_type: str or ~azure.communication.callautomation.TranscriptionTransportType
450-
:param locale: Defines the locale for the data e.g en-CA, en-AU. Required.
451-
:type locale: str
452-
:param speech_recognition_model_endpoint_id: Endpoint where the custom model was deployed.
453-
:type speech_recognition_model_endpoint_id: str
454-
:param start_transcription: Determines if the transcription should be started immediately after
452+
:paramtype transport_type: str or ~azure.communication.callautomation.TranscriptionTransportType
453+
:keyword locale: Defines the locale for the data e.g en-CA, en-AU. Required.
454+
:paramtype locale: str
455+
:keyword speech_recognition_model_endpoint_id: Endpoint where the custom model was deployed.
456+
:paramtype speech_recognition_model_endpoint_id: str
457+
:keyword start_transcription: Determines if the transcription should be started immediately after
455458
call is answered or not. Required.
456-
:type start_transcription: bool
457-
:param enable_intermediate_results: Enables intermediate results for the transcribed speech.
458-
:type enable_intermediate_results: bool
459+
:paramtype start_transcription: bool
460+
:keyword enable_intermediate_results: Enables intermediate results for the transcribed speech.
461+
:paramtype enable_intermediate_results: bool
459462
"""
460463

461464
transport_url: str
@@ -473,6 +476,7 @@ class TranscriptionOptions:
473476

474477
def __init__(
475478
self,
479+
*,
476480
transport_url: str,
477481
transport_type: Union[str, 'TranscriptionTransportType'],
478482
locale: str,
@@ -938,3 +942,114 @@ def _from_generated(cls, cancel_add_participant_operation_result_generated: 'Can
938942
invitation_id=cancel_add_participant_operation_result_generated.invitation_id,
939943
operation_context=cancel_add_participant_operation_result_generated.operation_context
940944
)
945+
946+
class ResultStatus(Enum):
947+
"""
948+
The status of the result of transcription.
949+
"""
950+
INTERMEDIATE = "intermediate"
951+
FINAL = "final"
952+
953+
class TextFormat(Enum):
954+
"""
955+
The format of transcription text.
956+
"""
957+
DISPLAY = "display"
958+
959+
class WordData:
960+
"""
961+
Text in the phrase.
962+
:keyword text: Text in the phrase.
963+
:paramtype text: str
964+
:keyword offset: The word's position within the phrase.
965+
:paramtype offset: int
966+
:keyword duration: Duration in ticks. 1 tick = 100 nanoseconds.
967+
:paramtype duration: int
968+
"""
969+
text:str
970+
""" Text in the phrase. """
971+
offset:int
972+
""" The word's position within the phrase. """
973+
duration:int
974+
""" Duration in ticks. 1 tick = 100 nanoseconds. """
975+
976+
def __init__(self, text: str, offset: int, duration: int):
977+
self.text = text
978+
self.offset = offset
979+
self.duration = duration
980+
981+
class TranscriptionMetadata:
982+
"""
983+
Metadata for Transcription Streaming.
984+
:keyword subscription_id: Transcription Subscription Id.
985+
:paramtype subscription_id: str
986+
:keyword locale: The target locale in which the translated text needs to be.
987+
:paramtype locale: str
988+
:keyword callConnection_id: call connection Id.
989+
:paramtype callConnection_id: str
990+
:keyword correlation_id: correlation Id.
991+
:paramtype correlation_id: str
992+
"""
993+
994+
subscription_id: str
995+
""" Transcription Subscription Id. """
996+
locale: str
997+
""" The target locale in which the translated text needs to be. """
998+
callConnection_id: str
999+
""" call connection Id. """
1000+
correlation_id: str
1001+
""" correlation Id. """
1002+
1003+
def __init__(self, subscription_id: str, locale: str, callConnection_id: str, correlation_id: str):
1004+
self.subscriptionId = subscription_id
1005+
self.locale = locale
1006+
self.callConnection_id = callConnection_id
1007+
self.correlation_id = correlation_id
1008+
1009+
class TranscriptionData:
1010+
"""
1011+
Streaming Transcription.
1012+
:keyword text: The display form of the recognized word.
1013+
:paramtype text: str
1014+
:keyword format: The format of text.
1015+
:paramtype format: TextFormat
1016+
:keyword confidence: Confidence of recognition of the whole phrase.
1017+
:paramtype confidence: float
1018+
:keyword offset: The position of this payload.
1019+
:paramtype offset: int
1020+
:keyword duration: Duration in ticks. 1 tick = 100 nanoseconds.
1021+
:paramtype duration: int
1022+
:keyword words: The result for each word of the phrase.
1023+
:paramtype words: List[WordData]
1024+
:keyword participant: The identified speaker based on participant raw ID.
1025+
:paramtype participant: CommunicationIdentifier
1026+
:keyword resultStatus: Status of the result of transcription.
1027+
:paramtype resultStatus: ResultStatus
1028+
"""
1029+
text: str
1030+
""" The display form of the recognized word. """
1031+
format: TextFormat
1032+
""" The format of text. """
1033+
confidence: float
1034+
""" Confidence of recognition of the whole phrase, from 0.0 (no confidence) to 1.0 (full confidence). """
1035+
offset: int
1036+
""" The position of this payload. """
1037+
duration: int
1038+
""" Duration in ticks. 1 tick = 100 nanoseconds. """
1039+
words: List[WordData]
1040+
""" The result for each word of the phrase. """
1041+
participant: CommunicationIdentifier
1042+
""" The identified speaker based on participant raw ID. """
1043+
result_status: ResultStatus
1044+
""" Status of the result of transcription. """
1045+
1046+
def __init__(self, text: str, format: TextFormat, confidence: float, offset: int, duration: int,
1047+
words: List[WordData], participant: CommunicationIdentifier, result_status: ResultStatus):
1048+
self.text = text
1049+
self.format = format
1050+
self.confidence = confidence
1051+
self.offset = offset
1052+
self.duration = duration
1053+
self.words = words
1054+
self.participant = participant
1055+
self.result_status = result_status

0 commit comments

Comments
 (0)