MCPcopy Create free account
hub / github.com/jasperproject/jasper-client / handle

Function handle

client/modules/MPDControl.py:12–50  ·  view source on GitHub ↗

Responds to user-input, typically speech text, by telling a joke. Arguments: text -- user-input, typically transcribed speech mic -- used to interact with the user (for both input and output) profile -- contains information related to the user (e.g., phone

(text, mic, profile)

Source from the content-addressed store, hash-verified

10
11
12def handle(text, mic, profile):
13 """
14 Responds to user-input, typically speech text, by telling a joke.
15
16 Arguments:
17 text -- user-input, typically transcribed speech
18 mic -- used to interact with the user (for both input and output)
19 profile -- contains information related to the user (e.g., phone
20 number)
21 """
22 logger = logging.getLogger(__name__)
23
24 kwargs = {}
25 if 'mpdclient' in profile:
26 if 'server' in profile['mpdclient']:
27 kwargs['server'] = profile['mpdclient']['server']
28 if 'port' in profile['mpdclient']:
29 kwargs['port'] = int(profile['mpdclient']['port'])
30
31 logger.debug("Preparing to start music module")
32 try:
33 mpdwrapper = MPDWrapper(**kwargs)
34 except:
35 logger.error("Couldn't connect to MPD server", exc_info=True)
36 mic.say("I'm sorry. It seems that Spotify is not enabled. Please " +
37 "read the documentation to learn how to configure Spotify.")
38 return
39
40 mic.say("Please give me a moment, I'm loading your Spotify playlists.")
41
42 # FIXME: Make this configurable
43 persona = 'JASPER'
44
45 logger.debug("Starting music mode")
46 music_mode = MusicMode(persona, mic, mpdwrapper)
47 music_mode.handleForever()
48 logger.debug("Exiting music mode")
49
50 return
51
52
53def isValid(text):

Callers

nothing calls this directly

Calls 4

handleForeverMethod · 0.95
MPDWrapperClass · 0.85
MusicModeClass · 0.85
sayMethod · 0.45

Tested by

no test coverage detected