Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pyCatSim/api/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}

Expand Down
4 changes: 4 additions & 0 deletions pyCatSim/tests/test_api_Cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ class TestcatCatNoise:
('meow', True),
('purr', False),
('purr', True),
('chatter', False),
('chatter', True),
('hiss', False),
('hiss', True),
('chirrup', False),
Expand All @@ -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':
Expand Down
37 changes: 34 additions & 3 deletions pyCatSim/utils/noises.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@

__all__=['meow',
'purr',
'chirrup']
'chatter',
'chirrup',
'hiss']

from playsound import playsound
import os
Expand Down Expand Up @@ -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):
"""
Expand All @@ -77,6 +98,7 @@ def chirrup(play=False):
If play is False, returns the sound as text

"""

if play is False:
return "Chirrup"
else:
Expand All @@ -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"))


Loading