Skip to content

Instantly share code, notes, and snippets.

@ichabodcole
ichabodcole / model_play.py
Created January 6, 2024 02:58
Combining XTTS speaker embeddings
import torch
from torch import Tensor
from TTS.api import TTS
from TTS.tts.configs.xtts_config import XttsConfig
from TTS.tts.models.xtts import Xtts
import utils
from utils import CombineMethod
from pydub import AudioSegment
from typing import List
@ichabodcole
ichabodcole / index.js
Created July 4, 2015 20:42
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
'use strict';
//var global = require('global');
//var document = require('global/document');
var immstruct = require('immstruct');
var hg = require('mercury');
var h = hg.h;
var ctx = new AudioContext();
@ichabodcole
ichabodcole / gist:c7c6a2007d18c94377ba
Created December 17, 2014 06:58
jasmine 2.1 - CustomMatcher -- toBeNearTo
jasmine.addMatchers({
toBeNearTo: function (utils, customEqualityTesters) {
return {
compare: function(actual, expected, within) {
var diff,
result = {};
within = Math.abs(within) || 1;
diff = Math.abs(actual - expected);
result.pass = diff <= within;
/*! Js Pub/Sub
* http://anasnakawa.com/
* Copyright (c) Anas Nakawa
* inspired by Ben Alman's one <https://gist.github.com/cowboy/661855>
* MIT License
*/
(function( p ) {
var e = p.e = {};
@ichabodcole
ichabodcole / Web Audio API - Sound Fading
Created July 3, 2013 18:40
Reference for fading in and out sounds with the Web Audio API
fadeTo: (value, fadeLength)->
fadeLength = fadeLength || @defaultfadeLength
currentTime = @ctx.currentTime
#time the fade should complete
fadeTime = currentTime + fadeLength
#set the start time
@masterGain.gain.setValueAtTime(@userVolume, currentTime)
@masterGain.gain.linearRampToValueAtTime(value, fadeTime)
fadeOut: (fadeLength)->
@ichabodcole
ichabodcole / robot_name.rb
Created March 25, 2013 21:53
Robot Name Warm-up
class Robot
def initialize
@count = 0;
@name = generate_name
@mac = generate_name + ":" + generate_name
@created_at = Time.now
@reset_at = 0
end
def generate_name
@ichabodcole
ichabodcole / gist:5209060
Created March 20, 2013 22:19
Deaf Grandma
class Grandma
def initialize
@message = "";
end
def speak_to(message)
if message == "BYE"
good_bye
return true
end
@ichabodcole
ichabodcole / gist:5206684
Created March 20, 2013 17:35
Scrabble Code
require 'minitest/spec'
require 'minitest/autorun'
require './scrabble.rb'
describe Scrabble do
describe "word_score" do
it "should return 14 if word is Cabbage" do
Scrabble.word_score("Cabbage").must_equal 14
end
@ichabodcole
ichabodcole / gist:5206677
Created March 20, 2013 17:35
Scrabble Tests
class Scrabble
# Note I cheated to get the values hash right,
# but cool thing is you can use integers as key values,
# which comes in handy below.
VALUES = {
1 => %w{a e i o u l n r s t},
2 => %w{d g},
3 => %w{b c m p},
4 => %w{f h v w y},
5 => %w{k},
@ichabodcole
ichabodcole / gist:4991398
Created February 19, 2013 23:53
Simple rack file loader.
class FileLoadingApp
def call(env)
m = nil
headers = {'content-type'=>'text/html'}
r = Rack::Request.new(env)
path = r.path.slice(1, r.path.size)
puts path
File.open(path, 'rt') do |f|
m = [200, headers, [f.read]]
puts m