Skip to content

Instantly share code, notes, and snippets.

View scottire's full-sized avatar

Scott Condron scottire

View GitHub Profile
@scottire
scottire / app.py
Created December 10, 2023 17:15
Transcribe, ChatGPT, gTTS
from flask import Flask, request, jsonify, send_file
import tempfile
import whisper
import gtts
import os
from openai import OpenAI
client = OpenAI()
conversation = []
@scottire
scottire / client.py
Created December 10, 2023 17:13
VAD and record audio
import pyaudio
import wave
import requests
import os
import sys
import webrtcvad
def record_audio(filename, duration=5):
vad = webrtcvad.Vad(1) # Set aggressiveness from 0 to 3
sample_rate = 16000 # Sample rate suitable for VAD
!curl -O https://calmcode.io/datasets/pokemon.json
import pandas
import weave
from weave.ecosystem import openai
from weave.ecosystem import umap
from weave.ecosystem import hdbscan
raw_data = pandas.read_json('./pokemon.json')
@scottire
scottire / sweeps_quickstart.py
Last active November 30, 2022 09:38
Get started tuning hyperparameters with W&B quickly
import wandb
# 1: Define objective/training function
def objective(config):
score = config.x ** 3 + config.y
return score
def main():
wandb.init(project='my-first-sweep')
score = objective(wandb.config)
@scottire
scottire / tconv.py
Last active June 15, 2021 11:48
PyTorch TransposeConvolution1d written in numpy
import numpy as np
import torch
import torch.nn as nn
import numpy as np
import panel as pn
from ipywidgets import widgets
from ipywidgets import interact, interactive, fixed, interact_manual
from IPython.display import display
import holoviews as hv
@scottire
scottire / interactive_audio_plots.py
Last active March 11, 2023 10:42
Interactive and clickable plots using Panel, Holoviz and Bokeh in Jupyter Notebooks
import numpy as np
import panel as pn
import holoviews as hv
hv.extension("bokeh")
# hv.extension('matplotlib')
from holoviews.streams import Stream, Params
from scipy.io import wavfile
from scipy.signal import spectrogram
rate, data = wavfile.read('/filepath.wav')
@scottire
scottire / link_audio_jupyter_wavesurfer.py
Last active June 1, 2020 12:59
Link timestamp from wavesurfer.js Audio visualisation to ipywidget slider using jp_proxy_widget
@scottire
scottire / ipywidgets_audio_plot.py
Last active June 1, 2020 15:59
Interactive Audio Plot using ipywidgets within Jupyter Notebook (not yet working with Jupyter Lab, see comments)
from ipywidgets import IntSlider, ToggleButton, Text
from IPython.display import display, Audio, Javascript
from scipy.io import wavfile
import numpy as np
from matplotlib import pyplot as plt
import ipywidgets
t = Text(value='0',
description='Elapsed Time:',
style = {'description_width': 'initial'},
import scipy.io as sio
import numpy as np
import os
import gc
import six.moves.urllib as urllib
import cv2
import time
import xml.etree.cElementTree as ET
import random
import shutil as sh
# --------------------------------------------------------
# Camera sample code for Tegra X2/X1
#
# This program could capture and display video from
# IP CAM, USB webcam, or the Tegra onboard camera.
# Refer to the following blog post for how to set up
# and run the code:
# https://jkjung-avt.github.io/tx2-camera-with-python/
#
# Written by JK Jung <[email protected]>