


'''simple docstring'''






import unittest

from datasets import load_dataset

from transformers.pipelines import pipeline
from transformers.testing_utils import is_pipeline_test, nested_simplify, require_torch, slow







@is_pipeline_test
@require_torch
class 			lowerCamelCase					(						unittest.TestCase  ):


					@require_torch
					def    SCREAMING_SNAKE_CASE_		(					self	:  List[str]       ):





											'''simple docstring'''





											_snake_case:   Dict  					=		pipeline(
											    task='zero-shot-audio-classification'       ,     model='hf-internal-testing/tiny-clap-htsat-unfused'       )
											_snake_case:   Optional[Any]  					=		load_dataset('ashraq/esc50'       )
											_snake_case:   int  					=		dataset['train']['audio'][-1]['array']
											_snake_case:   List[Any]  					=		audio_classifier(__snake_case       ,     candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']       )
											self.assertEqual(
											    nested_simplify(__snake_case       )       ,     [{'score': 0.501, 'label': 'Sound of a dog'}, {'score': 0.499, 'label': 'Sound of vaccum cleaner'}]       ,     )


					@unittest.skip('No models are available in TF'       )
					def    SCREAMING_SNAKE_CASE_		(					self	:  Tuple       ):





											'''simple docstring'''





											pass


					@slow
					@require_torch
					def    SCREAMING_SNAKE_CASE_		(					self	:  List[str]       ):





											'''simple docstring'''





											_snake_case:   Dict  					=		pipeline(
											    task='zero-shot-audio-classification'       ,     model='laion/clap-htsat-unfused'       ,     )
											# This is an audio of a dog
											_snake_case:   Optional[Any]  					=		load_dataset('ashraq/esc50'       )
											_snake_case:   Tuple  					=		dataset['train']['audio'][-1]['array']
											_snake_case:   Any  					=		audio_classifier(__snake_case       ,     candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']       )

											self.assertEqual(
											    nested_simplify(__snake_case       )       ,     [
											        {'score': 0.999, 'label': 'Sound of a dog'},
											        {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
											    ]       ,     )

											_snake_case:   List[Any]  					=		audio_classifier([audio] * 5       ,     candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']       )
											self.assertEqual(
											    nested_simplify(__snake_case       )       ,     [
											        [
											            {'score': 0.999, 'label': 'Sound of a dog'},
											            {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
											        ],
											    ]
											    * 5       ,     )
											_snake_case:   Tuple  					=		audio_classifier(
											    [audio] * 5       ,     candidate_labels=['Sound of a dog', 'Sound of vaccum cleaner']       ,     batch_size=5       )
											self.assertEqual(
											    nested_simplify(__snake_case       )       ,     [
											        [
											            {'score': 0.999, 'label': 'Sound of a dog'},
											            {'score': 0.001, 'label': 'Sound of vaccum cleaner'},
											        ],
											    ]
											    * 5       ,     )




					@unittest.skip('No models are available in TF'       )
					def    SCREAMING_SNAKE_CASE_		(					self	:  Any       ):





											'''simple docstring'''





											pass












'''simple docstring'''






from ..utils import DummyObject, requires_backends







class 			lowerCamelCase					(						metaclass=__UpperCAmelCase  ):
					_SCREAMING_SNAKE_CASE							   =    ["torch", "scipy"]


					def __init__(					self	:  Tuple       ,     *__snake_case	:  List[Any]       ,     **__snake_case	:  List[Any]       ):





											'''simple docstring'''





											requires_backends(self       ,     ['torch', 'scipy']       )


					@classmethod
					def    SCREAMING_SNAKE_CASE_		(					cls	:  Optional[int]       ,     *__snake_case	:  Optional[Any]       ,     **__snake_case	:  Tuple       ):





											'''simple docstring'''





											requires_backends(cls       ,     ['torch', 'scipy']       )




					@classmethod
					def    SCREAMING_SNAKE_CASE_		(					cls	:  List[Any]       ,     *__snake_case	:  Optional[Any]       ,     **__snake_case	:  str       ):





											'''simple docstring'''





											requires_backends(cls       ,     ['torch', 'scipy']       )





