- 進入 聲音控制畫面
alsamixer
- 調整 收音設定
f4
: capture - 測試收音 👉 錄音
- 結束錄音
ctrl+C
- 查看音檔(音檔在 /home/pi: 本地) :
ls
- 打開音檔
aplay test.wav
-
card: 2 device: 0
-
錄音
arecord --device=hw:2,0 --format S16_LE --rate 44100 -c1 test.wav -V mono
[color=red]要記得改!!!! card,device number : 2,0
-
播音
aplay --device=hw:1,0 test.wav
【Device number】 MICROPHONE: 2 speaker: 1
- 安裝 python pip
sudo apt install python3-pip
- 安裝picamara 套件
sudo pip3 install picamera
- enable picamara
sudo raspi-config
- enter interface option
- enter Camera to enable Yes
拍照和錄影都是加在if(BUTTON_STATUS==True):
後
- 拍照
#拍照
camera.annotate_text=dt.datetime.now().strftime('%Y/%m/%d %H:%M:%S')#加入時間戳
time.sleep(2)#暖機時間
camera.capture('testpic.jpg')#拍
camera.close()
- 錄影
#錄影
time.sleep(2)#暖機
camera.start_recording('video.h264')#錄
sleep(3)#camera.wait_recording#錄3秒
camera.stop_recording#停
camera.close()
- 目前全部
import RPi.GPIO as GPIO
import picamera
import time
import datetime as dt
GPIO.setmode(GPIO.BOARD)
BUTTON_PIN=37
GPIO.setup(BUTTON_PIN,GPIO.IN)
while True:
BUTTON_STATUS=GPIO.input(BUTTON_PIN)
if(BUTTON_STATUS==True):#按鈕
camera=picamera.PiCamera()
#拍照
#camera.annotate_text=dt.datetime.now().strftime('%Y/%m/%d %H:%M:%S')#加入時間戳
#time.sleep(2)#暖機時間
#camera.capture('testpic.jpg')#拍
#camera.close()
#錄影
time.sleep(2)#暖機
camera.start_recording('video.h264')#錄
sleep(3)#camera.wait_recording#錄3秒
camera.stop_recording#停
camera.close()
-
安裝telegram bot 相關套件
- 讀token:
sudo pip3 install python-dotenv
- 操作 Telegram Bot:
sudo pip3 install python-telegram-bot
-
引入套件
import telegram from telegram import Update, KeyboardButton, ReplyKeyboardMarkup, InlineKeyboardButton, InlineKeyboardMarkup from telegram.ext import Updater, CommandHandler, CallbackQueryHandler, CallbackContext, MessageHandler, Filters
-
引入token:
.env
# from tkinter import NO
from dotenv import load_dotenv
load_dotenv()
TOKEN = os.getenv("TOKEN")
updater = Updater(TOKEN)