Skip to content

Commit

Permalink
transferred work from thinkpad
Browse files Browse the repository at this point in the history
  • Loading branch information
hbarnard committed Jan 10, 2023
1 parent dd60004 commit ee09423
Show file tree
Hide file tree
Showing 14 changed files with 508 additions and 371 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ static/media/tmp/*
static/media/vid/*
static/media/pic/*
*.log
static/script/jquery-3.6.3.min.js
static/script/DataTables/datatables.min.css
static/script/DataTables/datatables.min.js

Binary file modified __pycache__/intent_server.cpython-39.pyc
Binary file not shown.
5 changes: 4 additions & 1 deletion etc/cron/make_cloud_and_vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ def get_stopwords():
stop_dict[line.rstrip()] = 1
return stop_dict

root_dir = '/home/hbarnard/projects/mema/'

#FIXME: probably need this for the moment, since its a cron, therefore full path
root_dir = '/home/pi/mema/'

config = configparser.ConfigParser()
config.read((root_dir + "etc/mema.ini"))
con = sqlite3.connect(config['main']['db'], check_same_thread=False)
Expand Down
4 changes: 3 additions & 1 deletion etc/mema.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ media_directory_url = static/media/
picture_program = /home/pi/mema/take_picture.py
story_program = /home/pi/mema/record_story.py
video_program = /home/pi/mema/record_video.py
env_file = /home/pi/.env

transcribe_program = /home/pi/whisper.cpp/main -f
# offline transcription, only really suitable for laptops at present
transcribe_program = /home/pi/whisper.cpp/main -m /home/pi/whisper.cpp/models/ggml-base.en.bin -f input -otxt /tmp/text

# time to reload rhasspy docker container tunable
rhasspy_reload = 10
Expand Down
116 changes: 67 additions & 49 deletions etc/mema_laptop.ini
Original file line number Diff line number Diff line change
@@ -1,87 +1,105 @@
#FIXME: arrgh, everything is apparently strings in this hence 'yes', 'no', rather than truth values
#FIXME: also home directory as ~ doesn't seem to expand
[main]
db = /var/spool/mema/db/memories.db
media_directory = /home/hbarnard/projects/mema/static/media/
pi = no
env_file = /home/hbarnard/.env
db = /home/hbarnard/mema/db/memories.db
media_directory = /home/hbarnard/mema/static/media/
media_directory_url = static/media/
picture_program = /home/hbarnard/projects/mema/take_picture.py
story_program = /home/hbarnard/projects/mema/record_story.py
video_program = /home/hbarnard/projects/mema/record_video.py
picture_program = /home/hbarnard/mema/take_picture.py
story_program = /home/hbarnard/mema/record_story.py
video_program = /home/hbarnard/mema/record_video.py

# prints lots of stuff on stdout
debug = False
# offline transcription, only really suitable for laptops at present
transcribe_program = /home/hbarnard/whisper.cpp/main -m /home/hbarnard/whisper.cpp/models/ggml-base.en.bin -f /tmp/tmp.wav -otxt

# set to false, to leave things unlabelled etc., since currently external service
use_external_ai = True
# time to reload rhasspy docker container tunable
rhasspy_reload = 10

#FIXME: logging used now: prepare for deb like directory structure, need config file though
debug = yes
logfile_name = var/spool/mema3.log

#FIXME: whisper.cpp soon set to false, to leave things unlabelled etc., since currently external service
#FIXME: needs to be on script by script basis, actually
use_external_ai = yes


#FIXME: now uses libcamera this is about the simplest set of options
#picture_command = libcamera-jpeg --nopreview -o
picture command = fswebcam -r 640x480 --jpeg 85 -D 1

## --- problematic video section --- ##
# this doesn't do sound currently, need to recompile ffmpeg or move to cvlc?
# pi video
#video_command = raspivid -o - -t 60000 -ex night -br 50 -w 1920 -h 1080 -rot 279 -fps 8 | sudo ffmpeg -nostats -loglevel 0 -r 8 -i - -y -vcodec copy
# laptop video, untested 8/11/2022
# changed to libcamera 12/12/2022
#video_command = libcamera-vid --nopreview -t video_maximum -o true_file_name
# video_command = nice cvlc v4l2:// :input-slave=alsa:// :v4l-vdev="/dev/video0"1:v4l-norm=3 :v4l-frequency=-1 :v4l-caching=300 :v4l-chroma="" :v4l-fps=-1.000000 :v4l-samplerate=44100 :v4l-channel=0 :v4l-tuner=-1 :v4l-audio=2 :v4l-stereo :v4l-width=480 :v4l-height=360 :v4l-brightness=-1 :v4l-colour=-1 :v4l-hue=-1 :v4l-contrast=-1 :no-v4l-mjpeg :gain=8 :v4l-decimation=1 :v4l-quality=100 --sout="#transcode{vcodec=theo,vb=2000,fps=12,scale=0.67,acodec=vorb,ab=90,channels=1,samplerate=44100}:duplicate{dst=display,dst=standard{access=file,mux=ogg, dst=file_name}}" --run-time 30 --stop-time=30 vlc://quit
#FIXME: needs work such as quiet log
video_command = ffmpeg -hide_banner -loglevel quiet -y -f alsa -i default -f v4l2 -i /dev/video0 -acodec aac -strict -2 -ac 1 -b:a 64k -vcodec libx264 -b:v 300k -r 30 -g 30 -t video_maximum true_file_path

#video_command = streamer -q -c /dev/video0 -f rgb24 -r 3 -t video_maximum -o tmp_file_name
video_command = ffmpeg -f alsa -i hw:0 -ac 1 -i /dev/video0 -t video_maximum tmp_file_name
#was -ac l: removed input is mono
# ffmpeg -f pulse -ac 2 -i default -f v4l2 -i /dev/video0 -t 00:00:20 -vcodec libx264 record.mp4

ffmpeg_command = ffmpeg -i file_name -c:v libx265 -x265-params lossless=1 -c:a libfdk_aac -b:a 128k -y output_file
# ffmpeg -t 60 -f video4linux2 -input_format mjpeg -i /dev/video0 -c:v libx264 -strict -2 outputs.mp4

# three minutes for testing, but usually we kill it
video_maximum = 30
# specific to vlc until method found to stop videorecording
kill_video_command = killall -s 9 vlc
#FIXME: thirty secs for testing, this is milliseconds, kill button?
video_maximum = '30'
#FIXME: needs testing until method found to stop videorecording
kill_video_command = killall -s 9 libcamera-vid

# --- audio recording section --- ##
# specific to laptop hardware, also 30 seconds only for testing
record_command = arecord -q -f cd -c 2 -D hw:0,0 --duration 30
#record_command = arecord -q -f cd -c 2 -D hw:0,0 --duration 30

# laptop record that is whisper.cpp compatible, to be modified for pi, mimic3 ?
#arecord -q -f S16_LE -r 16000 --device=plughw:1,0 --duration 30 example.wav

record_command = arecord -q -c 2 -f S16_LE -r 16000 -Dhw:0 --duration
downsample_command = ffmpeg -hide_banner -loglevel error -i file_path -vn -ar 16000 -ac 1 /tmp/tmp.wav
#arecord -v -D plughw:0 -r 16000 -c 2 -f S32_LE test.wav
# record maximum in seconds
audio_maximum = 30

#pi record using voice bonnet
# record_command = arecord -f cd -c 2 -D plug:dsnooped --duration 30
#record_command = arecord -f cd -c 2 -D plug:dsnooped --duration 30

#FIXME: label videos, needs work and uses external AI
label_program = /home/hbarnard/projects/mema/label_video.py
label_program = /home/hbarnard/mema/label_video.py

#xdg_open_command = exo-open --launch WebBrowser http://localhost:8000/memories
#xdg_open_command = export DISPLAY=:0.0 ; setuid 1000 ; /usr/bin/google-chrome-stable --no-sandbox http://localhost:8000/memories
#xdg_open_command = /usr/bin/google-chrome-stable http://localhost:8000/memories
xdg_open_command = handlr launch x-scheme-handler/http -- http://localhost:8000/memories.html
#xdg_open_command = /home/hbarnard/projects/mema/browser.py
xdg_search_open = xdg-open https://google.com?q=mema

keyword_slot_file = /home/hbarnard/.config/rhasspy/profiles/en/slots/keywords

intent_server = http://10.0.0.86:8000
confidence = 0.98
#xdg_open_command = jaro http://localhost:8000/memories.html

keyword_slot_file = ~/.config/rhasspy/profiles/en/slots/keywords

intent_server = http://localhost:8000

# voice recognition confidence
confidence = 0.98

rhasspy_main = http://localhost:12101
mimic3 = http://localhost:59125
node_red = http://localhost:1880

# this only affects the template directory at the moment
# Fixme
#FIXME: this only affects the template directory at the moment, start of internationalisation
language = en

#FIXME: some small prompts within the intent server, should be [prompts][en] to give full multilingual addressability
# with Mimic3 we can have voice ssml too, prosody speed
[en_prompts]
sorry = I_cannot_find_that_sorry
not_understood = Sorry_I_cannot_understand_that
start_record = starting to record wait for light
start_video = starting to video wait for light
end_record = finished recording starting to transcribe
end_video = finished recording video
end_transcription = finished transcription
taking_picture = taking picture now
trying_caption = trying to caption picture, please wait a moment
start_record = starting_to_record_wait_for_light
start_video = starting_to_video_wait_for_light
end_record = finished_recording_starting_to_transcribe
end_video = finished_recording_video
end_transcription = finished_transcription
taking_picture = taking_picture_now
trying_caption = trying_to_caption_picture_please_wait_a_moment
not_video = Sorry_this_is_not_a_video
didnt_get = Sorry_no_transcription try again
didnt_get = Sorry_no_transcription_try_again
nope = I'm_sorry_Dave_I'm_afraid_I_can't_do_that
ok_then = OK_then
done = Done and dusted
done = Done_and_dusted
what_kind = What_kind_of_pie_would_you_like?
ok_going = OK_here_we_go
#FIXME: should be [literals][en] as above
[en_literals]
unlabelled_video = unlabelled video recording
unlabelled_picture = unlabelled still image
unlabelled_audio = unlabelled audio recording
Loading

0 comments on commit ee09423

Please sign in to comment.