Skip to content

Instantly share code, notes, and snippets.

View thesanjeetc's full-sized avatar

Sanjeet thesanjeetc

View GitHub Profile
#You can import any modules required here
moduleName = "life"
commandWords = ["meaning","life"]
def execute(command):
print("The meaning of life is 42")
@thesanjeetc
thesanjeetc / cloudSettings
Last active June 28, 2021 13:51
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-06-28T13:51:18.119Z","extensionVersion":"v3.4.3"}
// When an ad is detected, this script mutes the Spotify music player and plays custom audio files instead
// Paste in console of web app / PWA
// Add your own audio file URLs below to replace the ads
// Or empty to play nothing
//-------------------------------------------------------//
let tunes = [
import re
with open('transcriptsOriginal.txt', 'r', encoding="utf8") as file:
data = file.read()
pattern = '\(.*\)\n|\[.*]|\(.*\)|PART.*]|…|Jamie:.*(.|\?)|[\?]|--|\.\.\.\s|Jaime(\n|.)*?\].'
result = re.sub(pattern, ' ', data)
result = result.replace('Elon Musk: ', 'ELON MUSK:\n')
result = result.replace('Joe Rogan: ', 'JOE ROGAN:\n')
# %tensorflow_version 1.x
# !pip install -q gpt-2-simple
import gpt_2_simple as gpt2
from datetime import datetime
from google.colab import files
gpt2.download_gpt2(model_name="355M")
file_name = "transcripts.txt"
gpt2.copy_file_from_gdrive(file_name)
sess = gpt2.start_tf_sess()
gpt2.finetune(sess,
dataset=file_name,
model_name='355M',
steps=1000,
restore_from='fresh',
run_name='run1',
print_every=10,
sample_every=200,
save_every=500
)
gpt2.copy_checkpoint_from_gdrive(run_name='run1')
sess = gpt2.start_tf_sess()
gpt2.load_gpt2(sess, run_name='run1')
gpt2.generate(sess,
length=800,
temperature=0.7,
prefix="JOE ROGAN:",
nsamples=5,
gen_file = 'gpt2_gentext_{:%Y%m%d_%H%M%S}.txt'.format(datetime.utcnow())
gpt2.generate_to_file(sess,
destination_path=gen_file,
length=500,
temperature=0.7,
nsamples=100,
batch_size=20
)
from google.cloud import texttospeech
import json
def tts(voice, dialog):
client = texttospeech.TextToSpeechClient()
input_text = texttospeech.SynthesisInput(text=dialog)
voice_config = texttospeech.VoiceSelectionParams(
language_code="en-US",