Skip to content

Instantly share code, notes, and snippets.

View kcarnold's full-sized avatar

Kenneth C. Arnold kcarnold

  • Grand Rapids, MI
View GitHub Profile
@kcarnold
kcarnold / video-subtitles-via-whisper.py
Last active October 25, 2022 16:08 — forked from rasbt/video-subtitles-via-whisper.py
Script that creates subtitles (closed captions) for all MP4 video files in your current directory
# Sebastian Raschka 09/24/2022
# Fixed to avoid problems with spaces and other special characters in filenames, Ken Arnold 10/25/2022
#
# Create a new conda environment and packages
# conda create -n whisper python=3.9
# conda activate whisper
# conda install mlxtend -c conda-forge
# Install ffmpeg
# macOS & homebrew
import pandas as pd
import sys
filename, outfile = sys.argv[1:3]
responses = pd.read_csv(filename)
def format_row(row):
return '\n'.join(["<p><b>{}</b><br>{}</p>".format(k, v.replace('\n', '<br>')) for k, v in row.iteritems()])
#!/usr/bin/env python
import numpy as np
import sys
from six import iteritems
from six.moves import zip as izip
from six.moves import xrange
from itertools import chain, repeat, islice
import sys
tr = [
(u'\u2018', "`"),
(u'\u2019',"'"),
(u'\u201c', "``"),
(u'\u201d', "''")
]
s = sys.stdin.read().decode('utf8')
for a, b in tr:
s = s.replace(a, b)