Skip to content

Instantly share code, notes, and snippets.

View alexlyzhov's full-sized avatar
🐵

Alexander alexlyzhov

🐵
  • NYU
  • New York City
View GitHub Profile
import json
import os
from collections import defaultdict
import numpy as np
from PIL import Image
class DSModel:
MODEL_REL_FILENAME = 'class.txt'
import json
import os
from collections import defaultdict
import numpy as np
from PIL import Image
MODEL_REL_FILENAME = 'class.txt'
class DSModel:
import pandas as pd
import itertools
five_csv = pd.read_csv('C:\\Users\\Alexander\\Documents\\downloads\\presidential_state_toplines_2020.csv')
states = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY']
five = [0.1514, 0.0164, 0.0095, 0.7112, 0.998, 0.9644, 0.9993, 1.0, 1.0, 0.6817, 0.5744, 0.9933, 0.3753, 0.0058, 0.9985, 0.0451, 0.0291, 0.0153, 0.027, 0.9995, 0.9995, 0.9068, 0.9506, 0.9585, 0.0711, 0.0858, 0.1565, 0.6461, 0.0226, 0.0058, 0.8886, 0.994, 0.9766, 0.873, 0.9999, 0.4913, 0.0056, 0.9782, 0.8726, 0.9993, 0.0916, 0.0524, 0.0294, 0.3945, 0.0421, 0.9899, 0.9951, 0.9917, 0.939, 0.0086, 0.0016]
econ = [0.0432, 0.0, 0.0, 0.7215, 1.0, 0.9983, 1.0, 1.0, 1.0, 0.7368, 0.534, 1.0, 0.3694, 0.0, 1.0, 0.0002, 0.0015, 0.0, 0.0004, 1.0, 1.0, 0.9984, 0.9759, 0.9
import pandas as pd
import itertools
states = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY']
five = [0.1514, 0.0164, 0.0095, 0.7112, 0.998, 0.9644, 0.9993, 1.0, 1.0, 0.6817, 0.5744, 0.9933, 0.3753, 0.0058, 0.9985, 0.0451, 0.0291, 0.0153, 0.027, 0.9995, 0.9995, 0.9068, 0.9506, 0.9585, 0.0711, 0.0858, 0.1565, 0.6461, 0.0226, 0.0058, 0.8886, 0.994, 0.9766, 0.873, 0.9999, 0.4913, 0.0056, 0.9782, 0.8726, 0.9993, 0.0916, 0.0524, 0.0294, 0.3945, 0.0421, 0.9899, 0.9951, 0.9917, 0.939, 0.0086, 0.0016]
econ = [0.0432, 0.0, 0.0, 0.7215, 1.0, 0.9983, 1.0, 1.0, 1.0, 0.7368, 0.534, 1.0, 0.3694, 0.0, 1.0, 0.0002, 0.0015, 0.0, 0.0004, 1.0, 1.0, 0.9984, 0.9759, 0.9824, 0.0155, 0.0034, 0.0094, 0.6486, 0.0, 0.0001, 0.9756, 1.0, 0.9965, 0.934, 1.0, 0.3337, 0.0, 1.0, 0.9309
import pandas as pd
import itertools
scores = {'AK': 0, 'AL': 0, 'AR': 0, 'AZ': 0.5, 'CA': 1, 'CO': 1, 'CT': 1, 'DC': 1, 'DE': 1, 'FL': 0, 'GA': 0.5, 'HI': 1, 'IA': 0, 'ID': 0, 'IL': 1, 'IN': 0, 'KS': 0, 'KY': 0, 'LA': 0, 'MA': 1, 'MD': 1, 'ME': 1, 'MI': 1, 'MN': 1, 'MO': 0, 'MS': 0, 'MT': 0, 'NC': 0.5, 'ND': 0, 'NE': 0, 'NH': 1, 'NJ': 1, 'NM': 1, 'NV': 0.5, 'NY': 1, 'OH': 0, 'OK': 0, 'OR': 1, 'PA': 0.5, 'RI': 1, 'SC': 0, 'SD': 0, 'TN': 0, 'TX': 0, 'UT': 0, 'VA': 1, 'VT': 1, 'WA': 1, 'WI': 1, 'WV': 0, 'WY': 0,}
state_list = ['AK', 'AL', 'AR', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'GA', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MI', 'MN', 'MO', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VT', 'WA', 'WI', 'WV', 'WY',]
five = [0.1514, 0.0164, 0.0095, 0.7112, 0.998, 0.9644, 0.9993, 1.0, 1.0, 0.6817, 0.5744, 0.9933, 0.3753, 0.0058, 0.9985, 0.0451, 0.0291, 0.0153, 0.027, 0.9995, 0.9995, 0.9068, 0.9506, 0
If Biden wins
538 Brier 0.1525, the Econ comment Brier 0.1502, the Econ csv brier 0.1502, (comment-spreadsheet) -0.000002 538-comment_Economist 0.0023 538-csv_Economist 0.0023
If Biden wins PA
538 Brier 0.1233, the Econ comment Brier 0.1164, the Econ csv brier 0.1164, (comment-spreadsheet) -0.000002 538-comment_Economist 0.0069 538-csv_Economist 0.0069
If Biden wins NV
538 Brier 0.1233, the Econ comment Brier 0.1162, the Econ csv brier 0.1162, (comment-spreadsheet) -0.000005 538-comment_Economist 0.0071 538-csv_Economist 0.0071
If Biden wins NV PA
538 Brier 0.0940, the Econ comment Brier 0.0824, the Econ csv brier 0.0824, (comment-spreadsheet) -0.000005 538-comment_Economist 0.0117 538-csv_Economist 0.0117
If Biden wins NC
538 Brier 0.1411, the Econ comment Brier 0.1386, the Econ csv brier 0.1386, (comment-spreadsheet) 0.000002 538-comment_Economist 0.0025 538-csv_Economist 0.0025
If Biden wins
538 Brier 0.1525, the Econ comment Brier 0.1502, the Econ spreadsheet brier 0.1502, (comment-spreadsheet) -0.000002 538-Economist 0.0023
If Biden wins PA
538 Brier 0.1233, the Econ comment Brier 0.1164, the Econ spreadsheet brier 0.1164, (comment-spreadsheet) -0.000002 538-Economist 0.0069
If Biden wins NV
538 Brier 0.1233, the Econ comment Brier 0.1162, the Econ spreadsheet brier 0.1162, (comment-spreadsheet) -0.000005 538-Economist 0.0071
If Biden wins NV PA
538 Brier 0.0940, the Econ comment Brier 0.0824, the Econ spreadsheet brier 0.0824, (comment-spreadsheet) -0.000005 538-Economist 0.0117
If Biden wins NC
538 Brier 0.1411, the Econ comment Brier 0.1386, the Econ spreadsheet brier 0.1386, (comment-spreadsheet) 0.000002 538-Economist 0.0025
If Biden wins no additional states
538 Brier 0.1525, the Economist Brier 0.1502, 538-Economist 0.0023
If Biden wins PA
538 Brier 0.1233, the Economist Brier 0.1164, 538-Economist 0.0069
If Biden wins NV
538 Brier 0.1233, the Economist Brier 0.1162, 538-Economist 0.0071
If Biden wins NV PA
538 Brier 0.0940, the Economist Brier 0.0824, 538-Economist 0.0117
If Biden wins NC
538 Brier 0.1411, the Economist Brier 0.1386, 538-Economist 0.0025
If Biden wins
538 Brier 0.1525, the Econ comment Brier 0.1502, the Econ csv brier 0.1502, (comment Brier - csv Brier) -0.000002 538-comment_Economist 0.0023 538-csv_Economist 0.0023
If Biden wins PA
538 Brier 0.1233, the Econ comment Brier 0.1164, the Econ csv brier 0.1164, (comment Brier - csv Brier) -0.000002 538-comment_Economist 0.0069 538-csv_Economist 0.0069
If Biden wins NV
538 Brier 0.1233, the Econ comment Brier 0.1162, the Econ csv brier 0.1162, (comment Brier - csv Brier) -0.000005 538-comment_Economist 0.0071 538-csv_Economist 0.0071
If Biden wins NV PA
538 Brier 0.0940, the Econ comment Brier 0.0824, the Econ csv brier 0.0824, (comment Brier - csv Brier) -0.000005 538-comment_Economist 0.0117 538-csv_Economist 0.0117
If Biden wins NC
538 Brier 0.1411, the Econ comment Brier 0.1386, the Econ csv brier 0.1386, (comment Brier - csv Brier) 0.000002 538-comment_Economist 0.0025 538-csv_Economist 0.0025
@alexlyzhov
alexlyzhov / whisper_with_vad.py
Created January 24, 2023 04:04
Whisper to json
# based on https://github.com/ANonEntity/WhisperWithVAD
import torch
import whisper
import os
import ffmpeg
import srt
from tqdm import tqdm
import datetime
import urllib.request