Skip to content

Instantly share code, notes, and snippets.

View jpsamaroo's full-sized avatar

Julian Samaroo jpsamaroo

View GitHub Profile
@jpsamaroo
jpsamaroo / run.jl
Created May 9, 2023 14:41
Whisper+PortAudio
using PortAudio, SampledSignals, Whisper
# Requires https://github.com/aviks/Whisper.jl/pull/8
ctx = Whisper.create_ctx("base.en")
wparams = Whisper.create_params()
wparams.n_threads = 6
queue = Channel(typemax(Int))
stream = PortAudioStream(1, 0)
function to_16k(buf)
using BenchmarkTools
function bench_async_yield(N, T)
ts = [@async begin
for i in 1:N
yield()
end
end for _ in 1:T]
wait.(ts)
end
function task_hook(code, to)
from_tls = task_local_storage()
if code == 0
to::Task
# Creation, setup child counters
@assert to.storage === nothing
to_tls = to.storage = IdDict{Any, Any}()
to_tls[:counter] = UInt64(0)
to_tls[:child_counter] = UInt64(0)
@jpsamaroo
jpsamaroo / ffmpeg-cut.jl
Created July 7, 2022 20:40
FFMPEG Cutting Script - in Julia
#!/usr/bin/env julia
function ts_to_s(ts::AbstractString)
secs = tryparse(Float64, ts)
if secs !== nothing
return secs
end
hours, mins, secs = parse.(Float64, split(ts, ':'))
return (hours * 60 * 60) + (mins * 60) + secs
end
@jpsamaroo
jpsamaroo / dagger-julius.jl
Created May 18, 2022 21:06
Julius Graph Benchmarks: Dagger and Dask
using Dagger
using Profile
fibsum(a, b) = .3 .* a .+ .7 .* b
function compute_sn_aot(N)
f0 = delayed(rand)(10)
f1 = delayed(rand)(10)
s = 0. # result held here
even = [f0]
@jpsamaroo
jpsamaroo / driver.jl
Created October 24, 2019 22:55
AMDGPUnative compiler/driver.jl WIP
# compiler driver and main interface
# (::CompilerJob)
const compile_hook = Ref{Union{Nothing,Function}}(nothing)
"""
compile(target::Symbol, agent::HSAAgent, f, tt, kernel=true;
libraries=true, optimize=true, strip=false, strict=true, ...)
Compile a function `f` invoked with types `tt` for agent `agent` to one of the