Skip to content

Instantly share code, notes, and snippets.

@jschwindt
Created April 23, 2023 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jschwindt/c82e7f6f0ee8e112e9b0aaf3c27ab5b6 to your computer and use it in GitHub Desktop.
Save jschwindt/c82e7f6f0ee8e112e9b0aaf3c27ab5b6 to your computer and use it in GitHub Desktop.
#!/usr/bin/env -S python -u
# pip install openai-whisper
# ./find_show_start.py lavenganza_2023-04-14.mp3-start.mp3
import whisper
import sys
import re
lvst = re.compile("la venganza ser[aá] terrible", re.IGNORECASE)
model = whisper.load_model("small")
result = model.transcribe(sys.argv[1], verbose=None, language="es", fp16=False)
prev_text = ""
prev_time = 0
for segment in result['segments']:
two_lines = prev_text + segment['text']
two_lines_time = prev_time
prev_time = segment['start']
prev_text = segment['text']
if lvst.search(segment['text']):
print(segment['start'])
sys.exit(0)
if lvst.search(two_lines):
print(two_lines_time)
sys.exit(0)
sys.exit(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment