Skip to content

Instantly share code, notes, and snippets.

View gpernelle's full-sized avatar

Guillaume Pernelle gpernelle

View GitHub Profile
@gpernelle
gpernelle / transcribe.py
Created September 22, 2024 06:13 — forked from scpedicini/transcribe.py
Python Dictation Transcription Application
# This script will transcribe an audio file (mp3, wav, etc.) to text and then clean the text using a local LLM model.
# GETTING STARTED:
# 1. Install openai
# 2. Git clone a copy of ggerganov/whisper (https://github.com/ggerganov/whisper.cpp)
# 3. Build the whisper binary
# 4. Download the whisper model (largev2 is the most accurate for all languages, though the base model works pretty well for English).
# 5. Install ffmpeg
# 6. Install ollama (https://ollama.com/download)
# 7. Download an LLM model (https://ollama.com/library)
@gpernelle
gpernelle / gist:4b54c78ec62797a28ec0fce2bd6cbdcc
Created September 22, 2024 06:13 — forked from adamsmith/gist:2a22b08d3d4a11fb9fe06531aea4d67c
voice-memo transcript → organized markdown text, using LLMs
There are two prompts, that chain together. The first prompt does most of the work, and the second prompt organizes the sections. I found because of the nature of how LLMs write, I couldn't get just one prompt to never jump back and forth in topics.
Prompt 1, which takes as input a raw transcript and generates a structured-text version...
"""# Instructions
A transcript is provided below of a voice memo I recorded as a "note to self". please extract all the points made or thoughts described, and put them in bullet-point form. use nested bullet points to indicate structure, e.g. a top-level bullet for each topic area and sub-bullets underneath. use multi-level nesting as appropriate to organize the thinking logically. use markdown formatting with `*` instead of `-` for bullet points.
DO NOT OMIT ANY POINTS MADE. This is not a summarization task — your only goal is to structure the thoughts there so they are logically organized and easy to read. Be concise because the reader is busy, but again DO NOT omit any
@gpernelle
gpernelle / read-access.sql
Created September 18, 2019 13:55 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
w = slicer.modules.NeedleFinderInstance
l = w.logic
case = 69
case_hd_filename = '/home/guillaume/Projects/github/3rd_stage/results/results-%d.csv' % case
stats_filename = '/home/guillaume/Projects/github/3rd_stage/results/avg-results-%s.csv' % args.filename
user = 0
results, outliers = l.evaluate(script=True) # calculate HD distances
for result in results:
result[0:0] = [user, case]
@gpernelle
gpernelle / one_needle_segmentation.py
Last active September 29, 2016 19:01
Programmatically start needle segmentation
### Use IJK coordinates to trigger an automatic needle segmentation
# get the module logic
w = slicer.modules.NeedleFinderWidget
l = w.logic
# create the template limit with the postion "templateLimit"
templateLimit = [0,0,-67] # in RAS coordinates. use l.ijk2ras if you need to do the conversion from IJK to RAS
l.fiducialNode = slicer.mrmlScene.CreateNodeByClass('vtkMRMLAnnotationFiducialNode')
l.fiducialNode.Initialize(slicer.mrmlScene)
@gpernelle
gpernelle / pg-pong.py
Created June 1, 2016 16:07 — forked from karpathy/pg-pong.py
Training a Neural Network ATARI Pong agent with Policy Gradients from raw pixels
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """
import numpy as np
import cPickle as pickle
import gym
# hyperparameters
H = 200 # number of hidden layer neurons
batch_size = 10 # every how many episodes to do a param update?
learning_rate = 1e-4
gamma = 0.99 # discount factor for reward