diff --git a/pyCatSim/api/cat.py b/pyCatSim/api/cat.py index d149216..5bae7bc 100644 --- a/pyCatSim/api/cat.py +++ b/pyCatSim/api/cat.py @@ -137,6 +137,8 @@ def make_noise(self, noise='meow', play=False): pyCatSim.utils.noises.purr: Simulates a cat purr + pyCatSim.utils.noises.chatter: Simulates a cat chatter + pyCatSim.utils.noises.hiss: Simulates a cat hiss pyCatSim.utils.noises.chirrup: Simulates a cat chirrup @@ -156,6 +158,7 @@ def make_noise(self, noise='meow', play=False): noise_func ={ 'meow':noises.meow, 'purr':noises.purr, + 'chatter':noises.chatter, 'hiss':noises.hiss, 'chirrup':noises.chirrup} diff --git a/pyCatSim/tests/test_api_Cat.py b/pyCatSim/tests/test_api_Cat.py index 0454556..f98e218 100644 --- a/pyCatSim/tests/test_api_Cat.py +++ b/pyCatSim/tests/test_api_Cat.py @@ -50,6 +50,8 @@ class TestcatCatNoise: ('meow', True), ('purr', False), ('purr', True), + ('chatter', False), + ('chatter', True), ('hiss', False), ('hiss', True), ('chirrup', False), @@ -69,6 +71,8 @@ def test_noise_t0(self,noise,play): assert v == 'Meow!' elif noise == 'purr': assert v == 'Purrr' + elif noise == 'chatter': + assert v == 'chattering' elif noise == 'hiss': assert v == 'Hiss..' elif noise == 'chirrup': diff --git a/pyCatSim/utils/noises.py b/pyCatSim/utils/noises.py index e864bf1..3cdb78a 100644 --- a/pyCatSim/utils/noises.py +++ b/pyCatSim/utils/noises.py @@ -7,7 +7,9 @@ __all__=['meow', 'purr', - 'chirrup'] + 'chatter', + 'chirrup', + 'hiss'] from playsound import playsound import os @@ -61,6 +63,25 @@ def purr(play=False): else: playsound(os.path.join(SOUND_DIR, "purr.mp3")) +def chatter(play=False): + """ + Simulates a chatter + + Parameters + ---------- + play : Bool, optional + Whether to play the sound (True) or display the text (False). The default is False. + + Returns + ------- + str + If play is False, returns the sound as text + """ + + if play is False: + return "chattering" + else: + playsound(os.path.join(SOUND_DIR, "chattering.mp3")) def chirrup(play=False): """ @@ -77,6 +98,7 @@ def chirrup(play=False): If play is False, returns the sound as text """ + if play is False: return "Chirrup" else: @@ -85,10 +107,19 @@ def chirrup(play=False): def hiss(play=False): """ Simulates a hiss + + Parameters + ---------- + play : Bool, optional + Whether to play the sound (True) or display the text (False). The default is False. + + Returns + ------- + str + If play is False, returns the sound as text + """ if play is False: return "Hiss.." else: playsound(os.path.join(SOUND_DIR, "hissing.mp3")) - -