Compare commits

..

5 Commits

Author SHA1 Message Date
78503d4349 Update 'raspberry.md' 2022-01-10 12:48:45 +00:00
Marcel Dechert
51fc3fb486 add some doc 2020-12-13 22:33:24 +01:00
Marcel Dechert
1b48ff1e79 swaghausen bot 2020-12-13 22:10:59 +01:00
Marcel Dechert
e9e2913346 telegram bot update 2020-12-13 22:03:35 +01:00
1dd31a32ec update 2020-12-05 21:31:58 +01:00
7 changed files with 83 additions and 10 deletions

View File

@@ -6,5 +6,6 @@ dependencies:
- numpy
- scipy
- matplotlib
- requests
- pip:
- sounddevice

View File

@@ -1,5 +1,9 @@
## connect via SSH
## PythonKlingelAnlage
- Better USB Micro
https://electronut.in/mico/
# Useful commands
- see connected usb devices
@@ -31,3 +35,8 @@ pcm.mic {
230000 array length
## Telegram Bot
SwaghausenBot
token:1456847960:AAHF6ZVfPrPedN07-Z0FlbtFzuUgpQM3iO4
chat_id:291512617
https://api.telegram.org/bot1456847960:AAHF6ZVfPrPedN07-Z0FlbtFzuUgpQM3iO4/getUpdates

59
requirements.txt Normal file
View File

@@ -0,0 +1,59 @@
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: win-64
blas=1.0=mkl
brotlipy=0.7.0=py36h2bbff1b_1003
ca-certificates=2020.12.8=haa95532_0
certifi=2020.12.5=py36haa95532_0
cffi=1.14.4=py36hcd4344a_0
chardet=3.0.4=py36haa95532_1003
cryptography=3.3.1=py36hcd4344a_0
cycler=0.10.0=py36haa95532_0
freetype=2.10.4=hd328e21_0
icc_rt=2019.0.0=h0cc432a_1
icu=58.2=ha925a31_3
idna=2.10=py_0
intel-openmp=2020.2=254
jpeg=9b=hb83a4c4_2
kiwisolver=1.3.0=py36hd77b12b_0
libpng=1.6.37=h2a8f88b_0
libtiff=4.1.0=h56a325e_1
lz4-c=1.9.2=hf4a77e7_3
matplotlib=3.3.2=0
matplotlib-base=3.3.2=py36hba9282a_0
mkl=2020.2=256
mkl-service=2.3.0=py36h196d8e1_0
mkl_fft=1.2.0=py36h45dec08_0
mkl_random=1.1.1=py36h47e9c7a_0
numpy=1.19.2=py36hadc3359_0
numpy-base=1.19.2=py36ha3acd2a_0
olefile=0.46=py36_0
openssl=1.1.1i=h2bbff1b_0
pillow=8.0.1=py36h4fa10fc_0
pip=20.3.1=py36haa95532_0
pycparser=2.20=py_2
pyopenssl=20.0.0=pyhd3eb1b0_1
pyparsing=2.4.7=py_0
pyqt=5.9.2=py36h6538335_2
pysocks=1.7.1=py36haa95532_0
python=3.6.12=h5500b2f_2
python-dateutil=2.8.1=py_0
qt=5.9.7=vc14h73c81de_0
requests=2.25.0=pyhd3eb1b0_0
scipy=1.5.2=py36h9439919_0
setuptools=51.0.0=py36haa95532_2
sip=4.19.8=py36h6538335_0
six=1.15.0=py36haa95532_0
sounddevice=0.4.1=pypi_0
sqlite=3.33.0=h2a8f88b_0
tk=8.6.10=he774522_0
tornado=6.1=py36h2bbff1b_0
urllib3=1.25.11=py_0
vc=14.2=h21ff451_1
vs2015_runtime=14.27.29016=h5e58377_2
wheel=0.36.1=pyhd3eb1b0_0
win_inet_pton=1.1.0=py36haa95532_0
wincertstore=0.2=py36h7fe50ca_0
xz=5.2.5=h62dcd97_0
zlib=1.2.11=h62dcd97_4
zstd=1.4.5=h04227a9_0

View File

@@ -48,7 +48,7 @@ SECONDS = (400000 / SAMPLE_RATE) / NUMBER_OF_SNIPPETS
snippets = []
i = 0
while True:
myrecording = sd.rec(int(SECONDS * SAMPLE_RATE), samplerate=SAMPLE_RATE, channels=2)
myrecording = sd.rec(int(SECONDS * SAMPLE_RATE), samplerate=48000, channels=1)
snippets.append(myrecording)
sd.wait()

Binary file not shown.

View File

@@ -2,17 +2,19 @@ import telegram_notifier
import logging
# telegram bot ---
TELEGRAM_TOKEN_ID = '1150602533:AAGSmPC0nGDYwiLQkkIlDheMzwR4TGv--sU' # token-id
TELEGRAM_TOKEN_ID = '1456847960:AAHF6ZVfPrPedN07-Z0FlbtFzuUgpQM3iO4' # token-id
TELEGRAM_CHAT_ID = '291512617' # chat-id
# ----------------
def send_notifaction(timestamp):
# - - - - - - - - - -
# Telegram notification:
msg = "Es hat geklingelt um {}".format(timestamp)
def send_notification(timestamp):
""" sends Telegram notification
using https://github.com/gvalvano/telegram-notification
"""
formatted_timestamp = timestamp.strftime("%d.%m.%Y, %H:%M:%S")
msg = "<b>Es hat geklingelt! </b> \nTimestamp: {}".format(formatted_timestamp)
telegram_notifier.basic_notifier(logger_name='training_notifier',
token_id=TELEGRAM_TOKEN_ID,
chat_id=TELEGRAM_CHAT_ID,
message=msg,
level=logging.INFO)

View File

@@ -4,11 +4,13 @@ import unittest
import telegram_bot
import datetime
class TestGetDataFromRKI(unittest.TestCase):
class SendTestMessageToSwaghausenBot(unittest.TestCase):
def test_send_notifaction(self):
timestamp = datetime.datetime.now()
telegram_bot.send_notifaction(timestamp)
telegram_bot.send_notification(timestamp)
if __name__ == '__main__':
unittest.main()