1
- # pylint: disable=too-many-lines
1
+ # pylint: disable=too-many-lines, disable=line-too-long, disable=too-many-locals
2
2
# -------------------------------------------------------------------------
3
3
# Copyright (c) Microsoft Corporation. All rights reserved.
4
4
# Licensed under the MIT License. See License.txt in the project root for
5
5
# license information.
6
6
# --------------------------------------------------------------------------
7
- from re import S
8
7
from typing import TYPE_CHECKING , Mapping , Optional , List , Sequence , Union , cast , overload
9
8
from urllib .parse import urlparse
10
9
import warnings
62
61
UnholdRequest ,
63
62
StartMediaStreamingRequest ,
64
63
StopMediaStreamingRequest ,
65
- SummarizeCallRequest
64
+ SummarizeCallRequest ,
66
65
)
67
66
from ._generated .models ._enums import RecognizeInputType
68
67
from ._shared .auth_policy_utils import get_authentication_policy
@@ -272,7 +271,7 @@ def transfer_call_to_participant(
272
271
user_custom_context : Optional [CustomCallingContext ] = CustomCallingContext (
273
272
voip_headers = dict (voip_headers ) if voip_headers is not None else None ,
274
273
sip_headers = dict (sip_headers ) if sip_headers is not None else None ,
275
- teams_phone_call_details = teams_phone_call_details ._to_generated () if teams_phone_call_details is not None else None ,
274
+ teams_phone_call_details = teams_phone_call_details ._to_generated () if teams_phone_call_details is not None else None , # pylint:disable=protected-access
276
275
)
277
276
else :
278
277
user_custom_context = None
@@ -345,7 +344,7 @@ def add_participant(
345
344
user_custom_context : Optional [CustomCallingContext ] = CustomCallingContext (
346
345
voip_headers = dict (voip_headers ) if voip_headers is not None else None ,
347
346
sip_headers = dict (sip_headers ) if sip_headers is not None else None ,
348
- teams_phone_call_details = teams_phone_call_details ._to_generated () if teams_phone_call_details is not None else None ,
347
+ teams_phone_call_details = teams_phone_call_details ._to_generated () if teams_phone_call_details is not None else None , # pylint:disable=protected-access
349
348
)
350
349
else :
351
350
user_custom_context = None
@@ -403,7 +402,7 @@ def remove_participant(
403
402
@distributed_trace
404
403
def move_participants (
405
404
self ,
406
- target_participants : List ["CommunicationIdentifier" ],
405
+ target_participants : Sequence ["CommunicationIdentifier" ],
407
406
from_call : str ,
408
407
* ,
409
408
operation_context : Optional [str ] = None ,
@@ -428,7 +427,7 @@ def move_participants(
428
427
:raises ~azure.core.exceptions.HttpResponseError:
429
428
"""
430
429
move_participants_request = MoveParticipantsRequest (
431
- target_participants = [serialize_identifier (participant ) for participant in target_participants ],
430
+ target_participants = [serialize_identifier (p ) for p in target_participants ],
432
431
from_call = from_call ,
433
432
operation_context = operation_context ,
434
433
operation_callback_uri = operation_callback_url ,
@@ -760,12 +759,20 @@ def start_recognizing_media(
760
759
:rtype: None
761
760
:raises ~azure.core.exceptions.HttpResponseError:
762
761
"""
762
+ speech_language_single : Optional [str ] = None
763
+ speech_languages : Optional [List [str ]] = None
764
+ if isinstance (speech_language , str ):
765
+ speech_language_single = speech_language
766
+ else :
767
+ speech_languages = list (speech_language ) if speech_language is not None else None
763
768
options = RecognizeOptions (
764
769
interrupt_prompt = interrupt_prompt ,
765
770
initial_silence_timeout_in_seconds = initial_silence_timeout ,
766
771
target_participant = serialize_identifier (target_participant ),
767
772
speech_recognition_model_endpoint_id = speech_recognition_model_endpoint_id ,
768
- enable_sentiment_analysis = enable_sentiment_analysis ,
773
+ enable_sentiment_analysis = enable_sentiment_analysis ,
774
+ speech_language = speech_language_single ,
775
+ speech_languages = speech_languages ,
769
776
)
770
777
play_prompt_single : Optional [PlaySource ] = None
771
778
play_prompts : Optional [List [PlaySource ]] = None
@@ -807,11 +814,9 @@ def start_recognizing_media(
807
814
recognize_input_type = input_type ,
808
815
play_prompt = play_prompt_single ,
809
816
play_prompts = play_prompts ,
810
- speech_languages = speech_language if isinstance (speech_language , list ) else None ,
811
817
interrupt_call_media_operation = interrupt_call_media_operation ,
812
818
operation_context = operation_context ,
813
819
recognize_options = options ,
814
- speech_language = speech_language if not isinstance (speech_language , list ) else None ,
815
820
operation_callback_uri = operation_callback_url ,
816
821
)
817
822
self ._call_media_client .recognize (self ._call_connection_id , recognize_request , ** kwargs )
@@ -997,7 +1002,7 @@ def start_transcription(
997
1002
998
1003
:keyword locale: Defines Locale for the transcription e,g en-US.
999
1004
List of languages for Language Identification.
1000
- :paramtype locale: str or Sequence [str]
1005
+ :paramtype locale: str or List [str]
1001
1006
:keyword operation_context: The value to identify context of the operation.
1002
1007
:paramtype operation_context: str
1003
1008
:keyword speech_recognition_model_endpoint_id: Endpoint where the custom model was deployed.
@@ -1019,14 +1024,20 @@ def start_transcription(
1019
1024
:raises ~azure.core.exceptions.HttpResponseError:
1020
1025
"""
1021
1026
1027
+ locale_single : Optional [str ] = None
1028
+ locales : Optional [List [str ]] = None
1029
+ if isinstance (locale , str ):
1030
+ locale_single = locale
1031
+ else :
1032
+ locales = list (locale ) if locale is not None else None
1022
1033
start_transcription_request = StartTranscriptionRequest (
1023
- locale = locale if not isinstance ( locale , list ) else None ,
1034
+ locale = locale_single ,
1024
1035
operation_context = operation_context ,
1025
1036
speech_recognition_model_endpoint_id = speech_recognition_model_endpoint_id ,
1026
1037
operation_callback_uri = operation_callback_url ,
1027
1038
pii_redaction_options = pii_redaction ._to_generated () if pii_redaction else None , # pylint:disable=protected-access
1028
1039
enable_sentiment_analysis = enable_sentiment_analysis ,
1029
- locales = locale if isinstance ( locale , list ) else None ,
1040
+ locales = locales ,
1030
1041
summarization_options = summarization ._to_generated () if summarization else None , # pylint:disable=protected-access
1031
1042
** kwargs
1032
1043
)
0 commit comments