From 8f2f4152b7408d80fb2155940980e370d19413cd Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Tue, 5 Nov 2024 19:51:05 +0530 Subject: [PATCH 01/10] Python SDK for transcription APIs --- plivo/resources/multipartycall.py | 21 ++++++--- plivo/resources/transcription.py | 42 ++++++++++++++++++ plivo/rest/client.py | 3 ++ .../fixtures/transcriptionCreateResponse.json | 4 ++ .../fixtures/transcriptionGetResponse.json | 9 ++++ tests/resources/test_transcriptions.py | 43 +++++++++++++++++++ 6 files changed, 116 insertions(+), 6 deletions(-) create mode 100644 plivo/resources/transcription.py create mode 100644 tests/resources/fixtures/transcriptionCreateResponse.json create mode 100644 tests/resources/fixtures/transcriptionGetResponse.json create mode 100644 tests/resources/test_transcriptions.py diff --git a/plivo/resources/multipartycall.py b/plivo/resources/multipartycall.py index 59a91140..1f95f672 100644 --- a/plivo/resources/multipartycall.py +++ b/plivo/resources/multipartycall.py @@ -63,7 +63,9 @@ def add_participant(self, stop_recording_audio_method='GET', create_mpc_with_single_participant=True, send_digits=None, - send_on_preanswer=False + send_on_preanswer=False, + transcription_url=None, + transcript=None ): return self.client.multi_party_calls.add_participant(role, uuid=self.id, **to_param_dict(self.add_participant, locals())) @@ -74,7 +76,8 @@ def start(self): def stop(self): return self.client.multi_party_calls.stop(uuid=self.id) - def start_recording(self, file_format=None, recording_callback_url=None, recording_callback_method=None): + def start_recording(self, file_format=None, recording_callback_url=None, recording_callback_method=None, + transcription_url=None, transcript=None): return self.client.multi_party_calls.start_recording(uuid=self.id, **to_param_dict(self.add_participant, locals())) @@ -88,7 +91,8 @@ def resume_recording(self): return self.client.multi_party_calls.resume_recording(uuid=self.id) def start_participant_recording(self, participant_id, file_format=None, recording_callback_url=None, - recording_callback_method=None, record_track_type='all'): + recording_callback_method=None, record_track_type='all', + transcription_url=None, transcript=None): return self.client.multi_party_calls.start_participant_recording(participant_id=participant_id, uuid=self.id, **to_param_dict( self.start_participant_recording, @@ -143,7 +147,8 @@ class MultiPartyCallParticipant(SecondaryPlivoResource): _secondary_identifier_string = 'member_id' def start_participant_recording(self, file_format=None, recording_callback_url=None, - recording_callback_method=None, record_track_type='all'): + recording_callback_method=None, record_track_type='all', + transcription_url=None, transcript=None): return self.client.multi_party_calls.start_participant_recording(participant_id=self.secondary_id, uuid=self.id, **to_param_dict( self.start_participant_recording, @@ -400,7 +405,9 @@ def add_participant(self, callback_method=None, create_mpc_with_single_participant=True, send_digits=None, - send_on_preanswer=False + send_on_preanswer=False, + transcription_url=None, + transcript=None ): mpc_id = self.__make_mpc_id(friendly_name, uuid) caller_name = caller_name or from_ @@ -466,7 +473,9 @@ def start_recording(self, recording_callback_url=None, recording_callback_method='POST', callback_url=None, - callback_method=None + callback_method=None, + transcription_url=None, + transcript=None ): mpc_id = self.__make_mpc_id(friendly_name, uuid) return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Record'), diff --git a/plivo/resources/transcription.py b/plivo/resources/transcription.py new file mode 100644 index 00000000..80159ecb --- /dev/null +++ b/plivo/resources/transcription.py @@ -0,0 +1,42 @@ +# -*- coding: utf-8 -*- +""" +Recording class - along with its list class +""" + +from plivo.base import (ListResponseObject, PlivoResource, + PlivoResourceInterface) +from plivo.resources.accounts import Subaccount +from plivo.utils import is_valid_time_comparison, to_param_dict +from plivo.utils.validators import * + + +class Transcription(PlivoResource): + _name = 'Transcription' + _identifier_string = 'transcription_id' + + def get_tanscription(self): + return self.client.transcriptions.get_tanscription(self.id, **to_param_dict(self.get_tanscription(), locals())) + + def create_tanscription(self): + return self.client.transcriptions.create_tanscription(self.id, **to_param_dict(self.create_tanscription(), locals())) + + +class Transcriptions(PlivoResourceInterface): + _resource_type = Transcription + + @validate_args(transcription_id=[of_type(six.text_type)] + ) + def get_tanscription(self, transcription_id, type=None): + if not type: + return self.client.request( + 'GET', ('Transcription', transcription_id), is_voice_request=True) + else: + return self.client.request( + 'GET', ('Transcription', transcription_id), to_param_dict(self.get_tanscription, locals()), is_voice_request=True) + + def create_tanscription(self, recording_id): + return self.client.request( + 'POST', ('Transcription', recording_id), is_voice_request=True) + + + diff --git a/plivo/rest/client.py b/plivo/rest/client.py index 19c2f24e..a24e9d60 100644 --- a/plivo/rest/client.py +++ b/plivo/rest/client.py @@ -18,6 +18,7 @@ TollfreeVerifications) from plivo.resources.live_calls import LiveCalls from plivo.resources.maskingsession import MaskingSessions +from plivo.resources.transcription import Transcriptions from plivo.resources.verify_callerid import VerifyCallerids from plivo.resources.profile import Profile from plivo.resources.queued_calls import QueuedCalls @@ -123,6 +124,8 @@ def __init__(self, auth_id=None, auth_token=None, proxies=None, timeout=5): self.voice_retry_count = 0 self.verify_session = Sessions(self) self.verify_callerids = VerifyCallerids(self) + self.transcriptions = Transcriptions(self) + def __enter__(self): return self diff --git a/tests/resources/fixtures/transcriptionCreateResponse.json b/tests/resources/fixtures/transcriptionCreateResponse.json new file mode 100644 index 00000000..eccd081b --- /dev/null +++ b/tests/resources/fixtures/transcriptionCreateResponse.json @@ -0,0 +1,4 @@ +{ + "api_id": "c9db3f38-55e8-4d97-93b2-1ece5a342528", + "message": "transcription in progress" +} \ No newline at end of file diff --git a/tests/resources/fixtures/transcriptionGetResponse.json b/tests/resources/fixtures/transcriptionGetResponse.json new file mode 100644 index 00000000..d1b33dc4 --- /dev/null +++ b/tests/resources/fixtures/transcriptionGetResponse.json @@ -0,0 +1,9 @@ +{ + "api_id": "f83b30a3-228c-4676-813e-985fcdf61201", + "cost": 0.05, + "rate": 0.05, + "recording_duration_ms": 22780, + "recording_start_ms": 1729761222174, + "status": "success", + "transcription": "\nSpeaker 0: Scan just to be safe. If you notice any error messages, please let me know immediately. They can help us diagnose the issue better. If it continues to freeze, we might need to look into your system performance. I can guide you through checking your task manager if that helps.\n\nSometimes, background processes can use up a lot of resources. I under" +} \ No newline at end of file diff --git a/tests/resources/test_transcriptions.py b/tests/resources/test_transcriptions.py new file mode 100644 index 00000000..8843d962 --- /dev/null +++ b/tests/resources/test_transcriptions.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- + +from datetime import datetime + +import plivo +from tests.base import PlivoResourceTestCase +from tests.decorators import with_response + + +class TranscriptionTest(PlivoResourceTestCase): + @with_response(200) + def test_get(self): + + transcription = self.client.transcriptions.get_tanscription( + 'ac28a19f-dc24-40ad-9745-7c29ee3f2c46') + + self.assertResponseMatches(transcription) + + # Verifying the endpoint hit + self.assertEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/ac28a19f-dc24-40ad-9745-7c29ee3f2c46/', + self.client.current_request.url) + + # Verifying the method used + self.assertEqual('GET', self.client.current_request.method) + + self.assertEqual('\nSpeaker 0: Scan just to be safe. If you notice any error messages, please let me know immediately. They can help us diagnose the issue better. If it continues to freeze, we might need to look into your system performance. I can guide you through checking your task manager if that helps.\n\nSometimes, background processes can use up a lot of resources. I under', transcription.transcription) + + def test_create(self): + transcription = self.client.transcriptions.create_tanscription( + 'ac28a19f-dc24-40ad-9745-7c29ee3f2c46') + + self.assertResponseMatches(transcription) + + # Verifying the endpoint hit + self.assertEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/ac28a19f-dc24-40ad-9745-7c29ee3f2c46/', + self.client.current_request.url) + + # Verifying the method used + self.assertEqual('POST', self.client.current_request.method) + + self.assertEqual('transcription in progress',transcription.message) \ No newline at end of file From 1f6615e2337680db638befe50e42c22bc95ad524 Mon Sep 17 00:00:00 2001 From: abinaya-plivo Date: Wed, 6 Nov 2024 13:20:33 +0530 Subject: [PATCH 02/10] added sdk versioning --- CHANGELOG.md | 8 ++++++++ plivo/resources/transcription.py | 7 +++++++ plivo/version.py | 2 +- setup.py | 2 +- 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e81a198a..c6308f44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,12 @@ # Change Log + +## [4.58.0](https://github.com/plivo/plivo-go/tree/v4.58.0) (2024-11-07) +**Feature - CreateRecordingTranscription, GetRecordingTranscription and DeleteRecordingTranscription feature added** +- Support added to create transcription for recorded calls for which transcription is not available and get API to retrieve and delete API to delete. +- Support for the `type` filter parameter, supported filters are transcription, raw and diarized +- Support for the `transcription_url` and `transcript` parameter in MPC Add Participant. +- Support added for Transcription params in MPC recording and MPC participant recording + ## [4.56.2](https://github.com/plivo/plivo-python/tree/v4.56.2) (2024-10-23) **Feature - FraudCheck param in Create, Get and List Session** - Support for the `fraud_check` parameter in sms verify session request diff --git a/plivo/resources/transcription.py b/plivo/resources/transcription.py index 80159ecb..170c7f2b 100644 --- a/plivo/resources/transcription.py +++ b/plivo/resources/transcription.py @@ -20,6 +20,9 @@ def get_tanscription(self): def create_tanscription(self): return self.client.transcriptions.create_tanscription(self.id, **to_param_dict(self.create_tanscription(), locals())) + def delete_tanscription(self): + return self.client.transcriptions.delete_tanscription(self.id, **to_param_dict(self.delete_tanscription(), locals())) + class Transcriptions(PlivoResourceInterface): _resource_type = Transcription @@ -38,5 +41,9 @@ def create_tanscription(self, recording_id): return self.client.request( 'POST', ('Transcription', recording_id), is_voice_request=True) + def delete_tanscription(self, transcription_id): + return self.client.request( + 'DELETE', ('Transcription', transcription_id), is_voice_request=True) + diff --git a/plivo/version.py b/plivo/version.py index 54ec96d7..ca614615 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.56.2' +__version__ = '4.58.0' diff --git a/setup.py b/setup.py index 13d28646..4c89acad 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.56.2', + version='4.58.0', description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML', long_description=long_description, url='https://github.com/plivo/plivo-python', From 621c693bd8d22be377c7f80f5ed1f8fbaa4b4c8b Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Mon, 11 Nov 2024 09:46:24 +0530 Subject: [PATCH 03/10] UTs added for delete transcription --- .../fixtures/transcriptionDeleteResponse.json | 4 +++ tests/resources/test_transcriptions.py | 26 +++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 tests/resources/fixtures/transcriptionDeleteResponse.json diff --git a/tests/resources/fixtures/transcriptionDeleteResponse.json b/tests/resources/fixtures/transcriptionDeleteResponse.json new file mode 100644 index 00000000..3b7a1023 --- /dev/null +++ b/tests/resources/fixtures/transcriptionDeleteResponse.json @@ -0,0 +1,4 @@ +{ +"api_id": "47ab0f0d-a7db-4f56-8200-6555cd3194e8", +"message": "request accepted" +} \ No newline at end of file diff --git a/tests/resources/test_transcriptions.py b/tests/resources/test_transcriptions.py index 8843d962..1fd8af5b 100644 --- a/tests/resources/test_transcriptions.py +++ b/tests/resources/test_transcriptions.py @@ -12,13 +12,13 @@ class TranscriptionTest(PlivoResourceTestCase): def test_get(self): transcription = self.client.transcriptions.get_tanscription( - 'ac28a19f-dc24-40ad-9745-7c29ee3f2c46') + 'e12d05fe-6979-485c-83dc-9276114dba3b') self.assertResponseMatches(transcription) # Verifying the endpoint hit self.assertEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/ac28a19f-dc24-40ad-9745-7c29ee3f2c46/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/e12d05fe-6979-485c-83dc-9276114dba3b/', self.client.current_request.url) # Verifying the method used @@ -28,16 +28,32 @@ def test_get(self): def test_create(self): transcription = self.client.transcriptions.create_tanscription( - 'ac28a19f-dc24-40ad-9745-7c29ee3f2c46') + 'e12d05fe-6979-485c-83dc-9276114dba3b') self.assertResponseMatches(transcription) # Verifying the endpoint hit self.assertEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/ac28a19f-dc24-40ad-9745-7c29ee3f2c46/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/e12d05fe-6979-485c-83dc-9276114dba3b/', self.client.current_request.url) # Verifying the method used self.assertEqual('POST', self.client.current_request.method) - self.assertEqual('transcription in progress',transcription.message) \ No newline at end of file + self.assertEqual('transcription in progress',transcription.message) + + def test_delete(self): + transcription = self.client.transcriptions.delete_tanscription( + 'e12d05fe-6979-485c-83dc-9276114dba3b') + + self.assertResponseMatches(transcription) + + # Verifying the endpoint hit + self.assertEqual( + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/ac28a19f-dc24-40ad-9745-7c29ee3f2c46/', + self.client.current_request.url) + + # Verifying the method used + self.assertEqual('DELETE', self.client.current_request.method) + + self.assertEqual('request accepted',transcription.message) \ No newline at end of file From 465e3c4cba4d7dcd0ac28423ea9f57225b024559 Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Mon, 11 Nov 2024 15:39:09 +0530 Subject: [PATCH 04/10] handled review comments --- CHANGELOG.md | 2 +- plivo/resources/multipartycall.py | 15 ++++++++------- plivo/version.py | 2 +- setup.py | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c6308f44..9bbbda78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.58.0](https://github.com/plivo/plivo-go/tree/v4.58.0) (2024-11-07) +## [4.57.0](https://github.com/plivo/plivo-go/tree/v4.57.0) (2024-11-07) **Feature - CreateRecordingTranscription, GetRecordingTranscription and DeleteRecordingTranscription feature added** - Support added to create transcription for recorded calls for which transcription is not available and get API to retrieve and delete API to delete. - Support for the `type` filter parameter, supported filters are transcription, raw and diarized diff --git a/plivo/resources/multipartycall.py b/plivo/resources/multipartycall.py index 1f95f672..dbfc99ca 100644 --- a/plivo/resources/multipartycall.py +++ b/plivo/resources/multipartycall.py @@ -65,7 +65,7 @@ def add_participant(self, send_digits=None, send_on_preanswer=False, transcription_url=None, - transcript=None + transcript=False ): return self.client.multi_party_calls.add_participant(role, uuid=self.id, **to_param_dict(self.add_participant, locals())) @@ -77,7 +77,7 @@ def stop(self): return self.client.multi_party_calls.stop(uuid=self.id) def start_recording(self, file_format=None, recording_callback_url=None, recording_callback_method=None, - transcription_url=None, transcript=None): + transcription_url=None, transcript=False): return self.client.multi_party_calls.start_recording(uuid=self.id, **to_param_dict(self.add_participant, locals())) @@ -92,7 +92,7 @@ def resume_recording(self): def start_participant_recording(self, participant_id, file_format=None, recording_callback_url=None, recording_callback_method=None, record_track_type='all', - transcription_url=None, transcript=None): + transcription_url=None, transcript=False): return self.client.multi_party_calls.start_participant_recording(participant_id=participant_id, uuid=self.id, **to_param_dict( self.start_participant_recording, @@ -148,7 +148,7 @@ class MultiPartyCallParticipant(SecondaryPlivoResource): def start_participant_recording(self, file_format=None, recording_callback_url=None, recording_callback_method=None, record_track_type='all', - transcription_url=None, transcript=None): + transcription_url=None, transcript=False): return self.client.multi_party_calls.start_participant_recording(participant_id=self.secondary_id, uuid=self.id, **to_param_dict( self.start_participant_recording, @@ -407,7 +407,7 @@ def add_participant(self, send_digits=None, send_on_preanswer=False, transcription_url=None, - transcript=None + transcript=False ): mpc_id = self.__make_mpc_id(friendly_name, uuid) caller_name = caller_name or from_ @@ -475,7 +475,7 @@ def start_recording(self, callback_url=None, callback_method=None, transcription_url=None, - transcript=None + transcript=False ): mpc_id = self.__make_mpc_id(friendly_name, uuid) return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Record'), @@ -599,7 +599,8 @@ def get_participant(self, participant_id, uuid=None, friendly_name=None, ) def start_participant_recording(self, participant_id, uuid=None, friendly_name=None, file_format='mp3', recording_callback_url=None, recording_callback_method='POST', - callback_url=None, callback_method=None, record_track_type='all'): + callback_url=None, callback_method=None, record_track_type='all', + transcription_url=None, transcript=False): mpc_id = self.__make_mpc_id(friendly_name, uuid) return self.client.request('POST', ('MultiPartyCall', mpc_id, 'Participant', participant_id, 'Record'), self.__clean_identifiers(to_param_dict(self.start_participant_recording, locals())), diff --git a/plivo/version.py b/plivo/version.py index ca614615..dbc23571 100644 --- a/plivo/version.py +++ b/plivo/version.py @@ -1,2 +1,2 @@ # -*- coding: utf-8 -*- -__version__ = '4.58.0' +__version__ = '4.57.0' diff --git a/setup.py b/setup.py index 4c89acad..1a9a12b0 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name='plivo', - version='4.58.0', + version='4.57.0', description='A Python SDK to make voice calls & send SMS using Plivo and to generate Plivo XML', long_description=long_description, url='https://github.com/plivo/plivo-python', From 8b80737c576aaf2459f34f0c4114daa93fa82351 Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Thu, 14 Nov 2024 13:45:21 +0530 Subject: [PATCH 05/10] added calllback url --- plivo/resources/transcription.py | 12 ++++-------- tests/resources/test_transcriptions.py | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/plivo/resources/transcription.py b/plivo/resources/transcription.py index 170c7f2b..888f1645 100644 --- a/plivo/resources/transcription.py +++ b/plivo/resources/transcription.py @@ -30,16 +30,12 @@ class Transcriptions(PlivoResourceInterface): @validate_args(transcription_id=[of_type(six.text_type)] ) def get_tanscription(self, transcription_id, type=None): - if not type: - return self.client.request( - 'GET', ('Transcription', transcription_id), is_voice_request=True) - else: - return self.client.request( + return self.client.request( 'GET', ('Transcription', transcription_id), to_param_dict(self.get_tanscription, locals()), is_voice_request=True) - def create_tanscription(self, recording_id): - return self.client.request( - 'POST', ('Transcription', recording_id), is_voice_request=True) + def create_tanscription(self, recording_id, transcription_callback_url=None): + return self.client.request( + 'POST', ('Transcription', recording_id), to_param_dict(self.create_tanscription, locals()), is_voice_request=True) def delete_tanscription(self, transcription_id): return self.client.request( diff --git a/tests/resources/test_transcriptions.py b/tests/resources/test_transcriptions.py index 1fd8af5b..9ea2cf11 100644 --- a/tests/resources/test_transcriptions.py +++ b/tests/resources/test_transcriptions.py @@ -26,34 +26,38 @@ def test_get(self): self.assertEqual('\nSpeaker 0: Scan just to be safe. If you notice any error messages, please let me know immediately. They can help us diagnose the issue better. If it continues to freeze, we might need to look into your system performance. I can guide you through checking your task manager if that helps.\n\nSometimes, background processes can use up a lot of resources. I under', transcription.transcription) + @with_response(201) def test_create(self): - transcription = self.client.transcriptions.create_tanscription( - 'e12d05fe-6979-485c-83dc-9276114dba3b') + self.client.transcriptions.create_tanscription( + recording_id='8605287e-1e1a-4341-8235-23574357d6f1') - self.assertResponseMatches(transcription) + # self.assertResponseMatches(transcription) # Verifying the endpoint hit + # self.assertUrlEqual( + # self.get_voice_url('Transcription', '8605287e-1e1a-4341-8235-23574357d6f1'), self.client.current_request.url) self.assertEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/e12d05fe-6979-485c-83dc-9276114dba3b/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/8605287e-1e1a-4341-8235-23574357d6f1/', self.client.current_request.url) # Verifying the method used self.assertEqual('POST', self.client.current_request.method) - self.assertEqual('transcription in progress',transcription.message) + # self.assertEqual('transcription in progress',transcription.message) + @with_response(202) def test_delete(self): transcription = self.client.transcriptions.delete_tanscription( - 'e12d05fe-6979-485c-83dc-9276114dba3b') + '8605287e-1e1a-4341-8235-23574357d6f1') self.assertResponseMatches(transcription) # Verifying the endpoint hit self.assertEqual( - 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/ac28a19f-dc24-40ad-9745-7c29ee3f2c46/', + 'https://api.plivo.com/v1/Account/MAXXXXXXXXXXXXXXXXXX/Transcription/8605287e-1e1a-4341-8235-23574357d6f1/', self.client.current_request.url) # Verifying the method used self.assertEqual('DELETE', self.client.current_request.method) - self.assertEqual('request accepted',transcription.message) \ No newline at end of file + self.assertEqual('request accepted', transcription.message) \ No newline at end of file From e46e9e63fcab1922e6f3718a1304306ea7ecea8e Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Thu, 14 Nov 2024 13:46:30 +0530 Subject: [PATCH 06/10] added 202 status code in delete --- plivo/rest/client.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plivo/rest/client.py b/plivo/rest/client.py index a24e9d60..378056b9 100644 --- a/plivo/rest/client.py +++ b/plivo/rest/client.py @@ -213,7 +213,7 @@ def process_response(self, '{url}'.format(url=response.url)) if method == 'DELETE': - if response.status_code not in [200, 204]: + if response.status_code not in [200, 202, 204]: raise PlivoRestError('Resource at {url} could not be ' 'deleted'.format(url=response.url)) From 33f4db6a28105c50a10a2f231862659d968062af Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Thu, 14 Nov 2024 13:57:38 +0530 Subject: [PATCH 07/10] corrected UTs --- plivo/resources/transcription.py | 6 +++++- tests/resources/test_transcriptions.py | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/plivo/resources/transcription.py b/plivo/resources/transcription.py index 888f1645..7c6c9825 100644 --- a/plivo/resources/transcription.py +++ b/plivo/resources/transcription.py @@ -30,7 +30,11 @@ class Transcriptions(PlivoResourceInterface): @validate_args(transcription_id=[of_type(six.text_type)] ) def get_tanscription(self, transcription_id, type=None): - return self.client.request( + if not type: + return self.client.request( + 'GET', ('Transcription', transcription_id), is_voice_request=True) + else: + return self.client.request( 'GET', ('Transcription', transcription_id), to_param_dict(self.get_tanscription, locals()), is_voice_request=True) def create_tanscription(self, recording_id, transcription_callback_url=None): diff --git a/tests/resources/test_transcriptions.py b/tests/resources/test_transcriptions.py index 9ea2cf11..c61ffaa6 100644 --- a/tests/resources/test_transcriptions.py +++ b/tests/resources/test_transcriptions.py @@ -11,8 +11,7 @@ class TranscriptionTest(PlivoResourceTestCase): @with_response(200) def test_get(self): - transcription = self.client.transcriptions.get_tanscription( - 'e12d05fe-6979-485c-83dc-9276114dba3b') + transcription = self.client.transcriptions.get_tanscription('e12d05fe-6979-485c-83dc-9276114dba3b') self.assertResponseMatches(transcription) From 15bf3033af951656989f93aced14eff867fb9a89 Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Thu, 14 Nov 2024 15:12:25 +0530 Subject: [PATCH 08/10] corrected UTs --- tests/resources/test_multipartycalls.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/resources/test_multipartycalls.py b/tests/resources/test_multipartycalls.py index 8d0fe81b..465c0958 100644 --- a/tests/resources/test_multipartycalls.py +++ b/tests/resources/test_multipartycalls.py @@ -190,7 +190,8 @@ def test_add_participant(self): 'start_recording_audio_method': 'GET', 'stop_recording_audio_method': 'GET', 'create_mpc_with_single_participant': True, - 'send_on_preanswer': False + 'send_on_preanswer': False, + 'transcript': False, } add_participant_response = self.client.multi_party_calls.add_participant(friendly_name='Voice', role='agent', @@ -431,7 +432,8 @@ def test_start_recording(self): expected_method='POST', expected_request_body={'file_format': 'wav', 'recording_callback_url': recording_callback_url, - 'recording_callback_method': 'POST'}, + 'recording_callback_method': 'POST', + 'transcript': False}, actual_response=start_recording_response) def test_stop_recording(self): @@ -489,7 +491,8 @@ def test_start_participant_recording(self): expected_request_body={'file_format': 'wav', 'recording_callback_url': recording_callback_url, 'recording_callback_method': 'POST', - 'record_track_type': 'all'}, + 'record_track_type': 'all', + 'transcript': False}, actual_response=start_participant_recording_response) def test_stop_participant_recording(self): From 70f8e2021cdf7fa8bc3b503beade3c735c9c1e9f Mon Sep 17 00:00:00 2001 From: Abinaya-Shunmugavel Date: Thu, 14 Nov 2024 18:01:23 +0530 Subject: [PATCH 09/10] corrected spelling --- plivo/resources/transcription.py | 22 +++++++++++----------- tests/resources/test_transcriptions.py | 6 +++--- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/plivo/resources/transcription.py b/plivo/resources/transcription.py index 7c6c9825..5301a7d8 100644 --- a/plivo/resources/transcription.py +++ b/plivo/resources/transcription.py @@ -14,14 +14,14 @@ class Transcription(PlivoResource): _name = 'Transcription' _identifier_string = 'transcription_id' - def get_tanscription(self): - return self.client.transcriptions.get_tanscription(self.id, **to_param_dict(self.get_tanscription(), locals())) + def get_transcription(self): + return self.client.transcriptions.get_transcription(self.id, **to_param_dict(self.get_transcription(), locals())) - def create_tanscription(self): - return self.client.transcriptions.create_tanscription(self.id, **to_param_dict(self.create_tanscription(), locals())) + def create_transcription(self): + return self.client.transcriptions.create_transcription(self.id, **to_param_dict(self.create_transcription(), locals())) - def delete_tanscription(self): - return self.client.transcriptions.delete_tanscription(self.id, **to_param_dict(self.delete_tanscription(), locals())) + def delete_transcription(self): + return self.client.transcriptions.delete_transcription(self.id, **to_param_dict(self.delete_transcription(), locals())) class Transcriptions(PlivoResourceInterface): @@ -29,19 +29,19 @@ class Transcriptions(PlivoResourceInterface): @validate_args(transcription_id=[of_type(six.text_type)] ) - def get_tanscription(self, transcription_id, type=None): + def get_transcription(self, transcription_id, type=None): if not type: return self.client.request( 'GET', ('Transcription', transcription_id), is_voice_request=True) else: return self.client.request( - 'GET', ('Transcription', transcription_id), to_param_dict(self.get_tanscription, locals()), is_voice_request=True) + 'GET', ('Transcription', transcription_id), to_param_dict(self.get_transcription, locals()), is_voice_request=True) - def create_tanscription(self, recording_id, transcription_callback_url=None): + def create_transcription(self, recording_id, transcription_callback_url=None): return self.client.request( - 'POST', ('Transcription', recording_id), to_param_dict(self.create_tanscription, locals()), is_voice_request=True) + 'POST', ('Transcription', recording_id), to_param_dict(self.create_transcription, locals()), is_voice_request=True) - def delete_tanscription(self, transcription_id): + def delete_transcription(self, transcription_id): return self.client.request( 'DELETE', ('Transcription', transcription_id), is_voice_request=True) diff --git a/tests/resources/test_transcriptions.py b/tests/resources/test_transcriptions.py index c61ffaa6..8b9b062f 100644 --- a/tests/resources/test_transcriptions.py +++ b/tests/resources/test_transcriptions.py @@ -11,7 +11,7 @@ class TranscriptionTest(PlivoResourceTestCase): @with_response(200) def test_get(self): - transcription = self.client.transcriptions.get_tanscription('e12d05fe-6979-485c-83dc-9276114dba3b') + transcription = self.client.transcriptions.get_transcription('e12d05fe-6979-485c-83dc-9276114dba3b') self.assertResponseMatches(transcription) @@ -27,7 +27,7 @@ def test_get(self): @with_response(201) def test_create(self): - self.client.transcriptions.create_tanscription( + self.client.transcriptions.create_transcription( recording_id='8605287e-1e1a-4341-8235-23574357d6f1') # self.assertResponseMatches(transcription) @@ -46,7 +46,7 @@ def test_create(self): @with_response(202) def test_delete(self): - transcription = self.client.transcriptions.delete_tanscription( + transcription = self.client.transcriptions.delete_transcription( '8605287e-1e1a-4341-8235-23574357d6f1') self.assertResponseMatches(transcription) From 8141af569ec7556d603a141c96106b8e96da7a62 Mon Sep 17 00:00:00 2001 From: Sandeep N Plivo <80757093+sandeep-plivo@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:36:14 +0530 Subject: [PATCH 10/10] Updated Date in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bbbda78..c1678126 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [4.57.0](https://github.com/plivo/plivo-go/tree/v4.57.0) (2024-11-07) +## [4.57.0](https://github.com/plivo/plivo-go/tree/v4.57.0) (2024-11-15) **Feature - CreateRecordingTranscription, GetRecordingTranscription and DeleteRecordingTranscription feature added** - Support added to create transcription for recorded calls for which transcription is not available and get API to retrieve and delete API to delete. - Support for the `type` filter parameter, supported filters are transcription, raw and diarized