diff --git a/test/__init__.py b/test/__init__.py index e69de29..8827667 100644 --- a/test/__init__.py +++ b/test/__init__.py @@ -0,0 +1,17 @@ +# coding: utf-8 + +""" + DeepAffects + + OpenAPI Specification of DeepAffects APIs + + OpenAPI spec version: 0.1.0 + + Generated by: https://github.com/swagger-api/swagger-codegen.git +""" + + +from __future__ import absolute_import + +# import apis into sdk package +from .test_base_setup import DIR \ No newline at end of file diff --git a/test/data/reconstructed.wav b/test/data/reconstructed.wav index fb3c9ec..58ec47a 100644 Binary files a/test/data/reconstructed.wav and b/test/data/reconstructed.wav differ diff --git a/test/test_denoise_api.py b/test/test_denoise_api.py index a6be930..f8b10c0 100644 --- a/test/test_denoise_api.py +++ b/test/test_denoise_api.py @@ -12,12 +12,13 @@ import os import sys import unittest - +import uuid import deepaffects from deepaffects.models.audio import Audio from .test_base_setup import DIR + class TestDenoiseApi(unittest.TestCase): """ DenoiseApi unit test stubs """ @@ -29,9 +30,21 @@ def sdr(clean, reconstructed): def setUp(self): deepaffects.configuration.api_key['apikey'] = os.environ['DEEPAFFECTS_API_KEY'] self.api = deepaffects.DenoiseApi() + self.webhook_url = os.environ["DEEPAFFECTS_API_WEBHOOK"] def tearDown(self): pass + def test_async_denoise_audio(self): + """ + Test case for sync_denoise_audio + + Denoise an audio file + """ + self.request_id = str(uuid.uuid4()) + test_noisy_audio = os.path.normpath(os.path.join(DIR, "data/noisy.wav")) + body = Audio.from_file(file_name=test_noisy_audio) + api_response = self.api.async_denoise_audio(body=body, webhook=self.webhook_url, request_id=self.request_id) + assert api_response.request_id, self.request_id def test_sync_denoise_audio(self): """ @@ -45,8 +58,7 @@ def test_sync_denoise_audio(self): body = Audio.from_file(file_name=test_noisy_audio) api_response = self.api.sync_denoise_audio(body=body) api_response.to_file(test_reconstructed_audio) - self.assertTrue(TestDenoiseApi.sdr(test_clean_audio, test_reconstructed_audio) > 5) - pass + assert TestDenoiseApi.sdr(test_clean_audio, test_reconstructed_audio) > 5 if __name__ == '__main__': diff --git a/test/test_diarize_api_v2.py b/test/test_diarize_api_v2.py index 2425bdb..c8c628f 100644 --- a/test/test_diarize_api_v2.py +++ b/test/test_diarize_api_v2.py @@ -12,7 +12,6 @@ import os import sys import unittest - import deepaffects from deepaffects import Audio from deepaffects.rest import ApiException @@ -27,23 +26,36 @@ class TestDiarizeApiV2(unittest.TestCase): def setUp(self): deepaffects.configuration.api_key['apikey'] = os.environ['DEEPAFFECTS_API_KEY'] self.webhook_url = os.environ["DEEPAFFECTS_API_WEBHOOK"] - self.api = deepaffects.apis.diarize_api_v2.DiarizeApiV2() - self.request_id = str(uuid.uuid4()) + self.api = deepaffects.apis.diarize_api_v2.DiarizeApiV2() def tearDown(self): pass - def test_async_diarize_audio(self): + def test_async_diarize_audio_with_request_id(self): """ Test case for diarize_audio Diarize an audio file """ + self.request_id = str(uuid.uuid4()) test_conversation_audio = os.path.normpath(os.path.join(DIR, "data/happy.mp3")) - body = Audio.from_file(file_name=test_conversation_audio) - + body = Audio.from_file(file_name=test_conversation_audio) api_response = self.api.async_diarize_audio(body=body, webhook=self.webhook_url, request_id=self.request_id) - self.assertTrue(api_response.request_id, self.request_id) + print(api_response) + assert api_response.request_id, self.request_id + + def test_async_diarize_audio_without_request_id(self): + """ + Test case for diarize_audio + + Diarize an audio file + """ + test_conversation_audio = os.path.normpath(os.path.join(DIR, "data/happy.mp3")) + body = Audio.from_file(file_name=test_conversation_audio) + api_response = self.api.async_diarize_audio(body=body, webhook=self.webhook_url) + print(api_response) + assert api_response.request_id + if __name__ == '__main__': - unittest.main() + unittest.main() \ No newline at end of file diff --git a/test/test_emotion_api.py b/test/test_emotion_api.py index 932f283..8ec8403 100644 --- a/test/test_emotion_api.py +++ b/test/test_emotion_api.py @@ -15,12 +15,13 @@ import unittest from deepaffects import Audio - +import uuid import deepaffects from deepaffects.rest import ApiException from deepaffects.apis.emotion_api import EmotionApi from deepaffects.models.emotion_score import EmotionScore -from .test_base_setup import DIR, AudioTest +from .test_base_setup import DIR + class TestEmotionApi(unittest.TestCase): @@ -28,18 +29,35 @@ class TestEmotionApi(unittest.TestCase): def setUp(self): deepaffects.configuration.api_key['apikey'] = os.environ['DEEPAFFECTS_API_KEY'] + self.webhook_url = os.environ["DEEPAFFECTS_API_WEBHOOK"] self.api = deepaffects.apis.emotion_api.EmotionApi() def tearDown(self): pass - def test_async_recognise_emotion(self): + def test_async_recognise_emotion_with_request_id(self): """ Test case for async_recognise_emotion Find emotion in an audio file """ - pass + self.request_id = str(uuid.uuid4()) + test_happy_audio = os.path.normpath(os.path.join(DIR, "data/happy.mp3")) + body = Audio.from_file(file_name=test_happy_audio) + api_response = self.api.async_recognise_emotion(body=body, webhook=self.webhook_url, request_id=self.request_id) + print(api_response) + assert api_response.request_id, self.request_id + def test_async_recognise_emotion_without_request_id(self): + """ + Test case for async_recognise_emotion + + Find emotion in an audio file + """ + test_happy_audio = os.path.normpath(os.path.join(DIR, "data/happy.mp3")) + body = Audio.from_file(file_name=test_happy_audio) + api_response = self.api.async_recognise_emotion(body=body, webhook=self.webhook_url) + print(api_response) + assert api_response.request_id def test_sync_recognise_emotion(self): """ @@ -50,6 +68,7 @@ def test_sync_recognise_emotion(self): test_happy_audio = os.path.normpath(os.path.join(DIR, "data/happy.mp3")) body = Audio.from_file(file_name=test_happy_audio) api_response = self.api.sync_recognise_emotion(body=body) + print(api_response) for obj in api_response: if obj.emotion == 'Happy': assert obj.score > 0.8 diff --git a/test/test_text_recoginse_emotion.py b/test/test_text_recoginse_emotion.py deleted file mode 100644 index ace85d2..0000000 --- a/test/test_text_recoginse_emotion.py +++ /dev/null @@ -1,52 +0,0 @@ -# coding: utf-8 - -""" - DeepAffects - - OpenAPI spec version: v1 -""" - - -from __future__ import absolute_import - -import os -import sys -import unittest - -import deepaffects -from deepaffects import Audio -from deepaffects.rest import ApiException -from deepaffects.apis.diarize_api_v2 import DiarizeApiV2 -DIR = os.path.dirname(os.path.realpath(__file__)) -import uuid - - -class TestTextEmootion(unittest.TestCase): - """ Text Emotion unit test stubs """ - - def setUp(self): - deepaffects.configuration.api_key['apikey'] = os.environ['DEEPAFFECTS_API_KEY'] - self.webhook_url = os.environ["DEEPAFFECTS_API_WEBHOOK"] - self.api = deepaffects.apis.emotion_api.EmotionApi() - self.request_id = str(uuid.uuid4()) - - def tearDown(self): - pass - - def test_async_diarize_audio(self): - """ - Test case for Text Emotion - - Diarize text file - """ - - body = { - "content": "Awesome" - } - api_response = self.api.sync_text_recognise_emotion(body=body) - print(api_response) - assert api_response['response']['trust']> 0.8 - - -if __name__ == '__main__': - unittest.main() diff --git a/test/test_text_recognise_emotion.py b/test/test_text_recognise_emotion.py new file mode 100644 index 0000000..778dfbe --- /dev/null +++ b/test/test_text_recognise_emotion.py @@ -0,0 +1,76 @@ +# coding: utf-8 + +""" + DeepAffects + + OpenAPI spec version: v1 +""" + + +from __future__ import absolute_import + +import os +import sys +import unittest + +sys.path.insert(0, '/Users/VivekNimkarde/DeepAffects/deepaffects-python') +import deepaffects +from deepaffects import Audio +from deepaffects.rest import ApiException +from .test_base_setup import DIR +import uuid + + +class TestTextEmootion(unittest.TestCase): + """ Text Emotion unit test stubs """ + + def setUp(self): + deepaffects.configuration.api_key['apikey'] = os.environ['DEEPAFFECTS_API_KEY'] + self.api = deepaffects.apis.emotion_api.EmotionApi() + + def tearDown(self): + pass + + def test_sync_diarize_audio_sample_text(self): + """ + Test case for Text Emotion + + Diarize text file + """ + + body = { + "content": "Awesome" + } + api_response = self.api.sync_text_recognise_emotion(body=body) + print(api_response) + assert api_response['response']['trust']> 0.8 + def test_sync_diarize_audio_check_response_field_exists(self): + """ + Test case for Text Emotion + + Diarize text file + """ + + body = { + "content": "Awesome" + } + api_response = self.api.sync_text_recognise_emotion(body=body) + print(api_response) + assert api_response['response'] + def test_sync_diarize_audio_check_version_field_exists(self): + """ + Test case for Text Emotion + + Diarize text file + """ + + body = { + "content": "Awesome" + } + api_response = self.api.sync_text_recognise_emotion(body=body) + print(api_response) + assert api_response['version'] + + +if __name__ == '__main__': + unittest.main()