squawk
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
squawk [2016-10-05 13:23] – rob | squawk [2016-10-09 22:31] – tim | ||
---|---|---|---|
Line 6: | Line 6: | ||
Sounds and TTS messages are triggered via the [[mqtt# | Sounds and TTS messages are triggered via the [[mqtt# | ||
+ | |||
+ | Examples for testing might be something like: | ||
+ | |||
+ | < | ||
+ | mosquitto_pub -h mqtt -t ' | ||
+ | mosquitto_pub -h mqtt -t ' | ||
+ | </ | ||
===== Raspbian ===== | ===== Raspbian ===== | ||
Line 13: | Line 20: | ||
==== raspi-config ==== | ==== raspi-config ==== | ||
+ | * Expand filesystem | ||
* Medium overclock | * Medium overclock | ||
* Graphics mem reduced to 16M | * Graphics mem reduced to 16M | ||
Line 39: | Line 47: | ||
< | < | ||
su -c " | su -c " | ||
- | su -c "/ | + | su -c "/ |
</ | </ | ||
- | |||
===== Scripts ===== | ===== Scripts ===== | ||
Line 57: | Line 64: | ||
import signal | import signal | ||
import time | import time | ||
+ | import random | ||
- | + | logging.basicConfig(level=logging.INFO) | |
- | last_state | + | |
max_playtime | max_playtime | ||
+ | sounds_path = "/ | ||
- | sounds_path | + | status |
# runs a command and terminates it after a specified timeout | # runs a command and terminates it after a specified timeout | ||
Line 123: | Line 131: | ||
base, ext = os.path.splitext(filename) | base, ext = os.path.splitext(filename) | ||
if ext == ' | if ext == ' | ||
- | command = [' | + | command = [' |
call_with_timeout(command, | call_with_timeout(command, | ||
else: | else: | ||
- | command = [' | + | command = [' |
call_with_timeout(command, | call_with_timeout(command, | ||
Line 132: | Line 140: | ||
client.subscribe(" | client.subscribe(" | ||
client.subscribe(" | client.subscribe(" | ||
+ | client.subscribe(" | ||
+ | client.subscribe(" | ||
+ | client.subscribe(" | ||
def on_message(client, | def on_message(client, | ||
+ | |||
+ | global status | ||
+ | |||
+ | if msg.topic == ' | ||
+ | if msg.payload == ' | ||
+ | | ||
+ | else: | ||
+ | | ||
# ignore retained (non-realtime) messages | # ignore retained (non-realtime) messages | ||
Line 140: | Line 159: | ||
if msg.topic == ' | if msg.topic == ' | ||
- | play(msg.payload) | + | |
if msg.topic == ' | if msg.topic == ' | ||
- | play('dong.mp3') | + | |
speak(msg.payload) | speak(msg.payload) | ||
- | | + | |
+ | if msg.topic == ' | ||
+ | play(' | ||
+ | speak(msg.payload) | ||
+ | |||
+ | if msg.topic == ' | ||
+ | if msg.payload == ' | ||
+ | play(' | ||
m = mqtt.Client() | m = mqtt.Client() | ||
Line 300: | Line 326: | ||
<code bash> | <code bash> | ||
#!/bin/bash | #!/bin/bash | ||
- | pico2wave -l en-GB -w /var/ | + | pico2wave -l en-GB -w / |
play -q / | play -q / | ||
rm -f / | rm -f / |
squawk.txt · Last modified: 2023-11-25 23:45 by jaso55555