Skip to content

Commit ab96281

Browse files
author
Vinothini Dharmaraj
committed
Fixing the tests and rerecording the test data
1 parent 70e6214 commit ab96281

File tree

6 files changed

+236
-385
lines changed

6 files changed

+236
-385
lines changed

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

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from ._version import VERSION
99
from ._call_automation_client import CallAutomationClient
1010
from ._call_connection_client import CallConnectionClient
11-
from ._streaming_data_parser import StreamingDataParser
1211
from ._models import (
1312
CallConnectionProperties,
1413
FileSource,
@@ -32,11 +31,7 @@
3231
ServerCallLocator,
3332
GroupCallLocator,
3433
AzureBlobContainerRecordingStorage,
35-
AzureCommunicationsRecordingStorage,
36-
AudioMetadata,
37-
AudioData,
38-
TranscriptionMetadata,
39-
TranscriptionData
34+
AzureCommunicationsRecordingStorage
4035
)
4136
from ._shared.models import (
4237
CommunicationIdentifier,
@@ -74,9 +69,6 @@
7469
"CallAutomationClient",
7570
"CallConnectionClient",
7671

77-
# parser
78-
"StreamingDataParser",
79-
8072
# models for input
8173
"FileSource",
8274
"TextSource",
@@ -89,10 +81,6 @@
8981
"TranscriptionSubscription",
9082
"AzureBlobContainerRecordingStorage",
9183
"AzureCommunicationsRecordingStorage",
92-
"AudioMetadata",
93-
"AudioData",
94-
"TranscriptionMetadata",
95-
"TranscriptionData",
9684

9785
# models for output
9886
"CallConnectionProperties",

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

Lines changed: 0 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
# --------------------------------------------------------------------------
77

88
from typing import List, Optional, Union, TYPE_CHECKING
9-
from enum import Enum
10-
from datetime import datetime
119
from typing_extensions import Literal
1210
from ._generated.models import (
1311
CallLocator,
@@ -966,188 +964,3 @@ def _from_generated(cls, cancel_add_participant_operation_result_generated: 'Can
966964
invitation_id=cancel_add_participant_operation_result_generated.invitation_id,
967965
operation_context=cancel_add_participant_operation_result_generated.operation_context
968966
)
969-
970-
class TextFormat(Enum):
971-
"""
972-
The format of transcription text.
973-
"""
974-
DISPLAY = "display"
975-
976-
class WordData:
977-
"""
978-
Text in the phrase.
979-
:keyword text: Text in the phrase.
980-
:paramtype text: str
981-
:keyword offset: The word's position within the phrase.
982-
:paramtype offset: int
983-
:keyword duration: Duration in ticks. 1 tick = 100 nanoseconds.
984-
:paramtype duration: int
985-
"""
986-
text:str
987-
""" Text in the phrase. """
988-
offset:int
989-
""" The word's position within the phrase. """
990-
duration:int
991-
""" Duration in ticks. 1 tick = 100 nanoseconds. """
992-
993-
def __init__(self, text: str, offset: int, duration: int):
994-
self.text = text
995-
self.offset = offset
996-
self.duration = duration
997-
998-
class TranscriptionMetadata:
999-
"""
1000-
Metadata for Transcription Streaming.
1001-
:keyword subscription_id: Transcription Subscription Id.
1002-
:paramtype subscription_id: str
1003-
:keyword locale: The target locale in which the translated text needs to be.
1004-
:paramtype locale: str
1005-
:keyword callConnection_id: call connection Id.
1006-
:paramtype callConnection_id: str
1007-
:keyword correlation_id: correlation Id.
1008-
:paramtype correlation_id: str
1009-
"""
1010-
1011-
subscription_id: str
1012-
""" Transcription Subscription Id. """
1013-
locale: str
1014-
""" The target locale in which the translated text needs to be. """
1015-
call_connection_id: str
1016-
""" call connection Id. """
1017-
correlation_id: str
1018-
""" correlation Id. """
1019-
1020-
def __init__(
1021-
self,
1022-
*,
1023-
subscription_id: str,
1024-
locale: str,
1025-
call_connection_id: str,
1026-
correlation_id: str):
1027-
self.subscription_id = subscription_id
1028-
self.locale = locale
1029-
self.call_connection_id = call_connection_id
1030-
self.correlation_id = correlation_id
1031-
1032-
class TranscriptionData:
1033-
"""
1034-
Streaming Transcription.
1035-
:keyword text: The display form of the recognized word.
1036-
:paramtype text: str
1037-
:keyword format: The format of text.
1038-
:paramtype format: TextFormat
1039-
:keyword confidence: Confidence of recognition of the whole phrase.
1040-
:paramtype confidence: float
1041-
:keyword offset: The position of this payload.
1042-
:paramtype offset: int
1043-
:keyword duration: Duration in ticks. 1 tick = 100 nanoseconds.
1044-
:paramtype duration: int
1045-
:keyword words: The result for each word of the phrase.
1046-
:paramtype words: List[WordData]
1047-
:keyword participant: The identified speaker based on participant raw ID.
1048-
:paramtype participant: CommunicationIdentifier
1049-
:keyword result_state: Status of the result of transcription.
1050-
:paramtype result_state: str or
1051-
~azure.communication.callautomation.models.TranscriptionResultState
1052-
"""
1053-
text: str
1054-
""" The display form of the recognized word. """
1055-
format: TextFormat
1056-
""" The format of text. """
1057-
confidence: float
1058-
""" Confidence of recognition of the whole phrase, from 0.0 (no confidence) to 1.0 (full confidence). """
1059-
offset: int
1060-
""" The position of this payload. """
1061-
duration: int
1062-
""" Duration in ticks. 1 tick = 100 nanoseconds. """
1063-
words: List[WordData]
1064-
""" The result for each word of the phrase. """
1065-
participant: CommunicationIdentifier
1066-
""" The identified speaker based on participant raw ID. """
1067-
result_state: 'TranscriptionResultState'
1068-
""" State of the result of transcription. """
1069-
1070-
def __init__(
1071-
self,
1072-
*,
1073-
text: str,
1074-
format: TextFormat,
1075-
confidence: float,
1076-
offset: int,
1077-
duration: int,
1078-
words: List[WordData],
1079-
participant: CommunicationIdentifier,
1080-
result_state: 'TranscriptionResultState'):
1081-
self.text = text
1082-
self.format = format
1083-
self.confidence = confidence
1084-
self.offset = offset
1085-
self.duration = duration
1086-
self.words = words
1087-
self.participant = participant
1088-
self.result_state = result_state
1089-
1090-
class AudioMetadata:
1091-
"""
1092-
Metadata for Audio Streaming.
1093-
:keyword subscription_id: Audio subscription id.
1094-
:paramtype subscription_id: str
1095-
:keyword encoding: Audio encoding.
1096-
:paramtype encoding: str
1097-
:keyword sample_rate: Audio sample rate.
1098-
:paramtype sample_rate: int
1099-
:keyword channels: Audio channels.
1100-
:paramtype channels: int
1101-
:keyword length: Audio length.
1102-
:paramtype length: int
1103-
"""
1104-
subscription_id: str
1105-
""" Audio subscription id. """
1106-
encoding: str
1107-
""" Audio encoding. """
1108-
sample_rate: int
1109-
""" Audio sample rate. """
1110-
channels: int
1111-
""" Audio channels. """
1112-
length: int
1113-
""" Audio length. """
1114-
1115-
def __init__(
1116-
self,
1117-
*,
1118-
subscription_id: str,
1119-
encoding: str,
1120-
sample_rate: int,
1121-
channels: int,
1122-
length: int):
1123-
self.subscription_id = subscription_id
1124-
self.encoding = encoding
1125-
self.sample_rate = sample_rate
1126-
self.channels = channels
1127-
self.length = length
1128-
1129-
class AudioData:
1130-
"""
1131-
Data for Audio Streaming.
1132-
:keyword data: Audio streaming data.
1133-
:paramtype data: str
1134-
:keyword time_stamp: time stamp.
1135-
:paramtype time_stamp: datetime
1136-
:keyword is_silent: Is silent.
1137-
:paramtype is_silent: bool
1138-
"""
1139-
data: str
1140-
""" Audio streaming data. """
1141-
time_stamp : datetime
1142-
""" Time stamp. """
1143-
is_silent : bool
1144-
""" Is silent. """
1145-
def __init__(
1146-
self,
1147-
*,
1148-
data: str,
1149-
time_stamp: str,
1150-
is_silent: bool):
1151-
self.data = data
1152-
self.time_stamp = time_stamp
1153-
self.is_silent = is_silent

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

Lines changed: 0 additions & 80 deletions
This file was deleted.

sdk/communication/azure-communication-callautomation/tests/callautomation_test_case.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import inspect
1111
from datetime import datetime, timedelta
12-
from typing import Dict, Any, List
12+
from typing import Dict, Any, List, Optional
1313

1414
import requests
1515
from azure.servicebus import ServiceBusClient
@@ -170,7 +170,7 @@ def check_for_event(self, event_type: str, call_connection_id: str, wait_time: t
170170
time.sleep(1)
171171
return None
172172

173-
def establish_callconnection_voip(self, caller, target) -> tuple:
173+
def establish_callconnection_voip(self, caller, target, *, cognitive_service_enabled: Optional[bool] = False) -> tuple:
174174
call_automation_client_caller = CallAutomationClient.from_connection_string(self.connection_str, source=caller) # for creating call
175175
call_automation_client_target = CallAutomationClient.from_connection_string(self.connection_str, source=target) # answering call, all other actions
176176

@@ -189,7 +189,10 @@ def establish_callconnection_voip(self, caller, target) -> tuple:
189189
thread.start()
190190

191191
# create a call
192-
create_call_result = call_automation_client_caller.create_call(target_participant=target, callback_url=(self.dispatcher_callback + "?q={}".format(unique_id)))
192+
create_call_result = call_automation_client_caller.create_call(
193+
target_participant=target,
194+
callback_url=(self.dispatcher_callback + "?q={}".format(unique_id)),
195+
cognitive_services_endpoint=self.cognitive_service_endpoint if cognitive_service_enabled else None)
193196

194197
if create_call_result is None:
195198
raise ValueError("Invalid create_call_result")

0 commit comments

Comments
 (0)