-
Notifications
You must be signed in to change notification settings - Fork 1
/
Volume.py
35 lines (28 loc) · 975 Bytes
/
Volume.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# -*- coding: utf-8-*-
import re
from os import system
WORDS = ["VOLUME", "SOUND"]
def handle(text, mic, profile):
"""
Responds to user-input, typically speech text, with a summary of
the relevant weather for the requested date (typically, weather
information will not be available for days beyond tomorrow).
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
number)
"""
if "up" in text:
action = '+'
elif "down" in text:
action = '-'
system("amixer -c 1 set PCM 1000" + action)
mic.say("Ok, " + text)
def isValid(text):
"""
Returns True if the text is related to the weather.
Arguments:
text -- user-input, typically transcribed speech
"""
return any(word in text.upper() for word in WORDS)