Skip to content

Instantly share code, notes, and snippets.

@Olshansk
Olshansk / llm.sh
Last active September 28, 2024 00:47
A bash wrapper around python's mlx_whisper to leverage the GPU on a mac for transcription
# A one liner to leverage the GPU on a mac to transcribe audio files
# Inspired by https://simonwillison.net/2024/Aug/13/mlx-whisper/
llm_transcribe_recording () {
local file_path="$1"
python3 -c "
import mlx_whisper
result = mlx_whisper.transcribe('$file_path', path_or_hf_repo='mlx-community/distil-whisper-large-v3')
print(result['text'])
"
}
@rtkclouds
rtkclouds / idNorm_py.py
Last active November 23, 2023 04:00
The layer includes a custom hashing function. Hash functions are often used in neural networks for dimensionality
import torch
import torch.nn as nn
import math
class IdNorm(nn.Module):
def __init__(self, cluster_size=128):
super(IdNorm, self).__init__()
self.cluster_size = cluster_size
self.n = None # Será definido no método build
self.embs = nn.ModuleList()