Created
April 23, 2023 19:21
-
-
Save jschwindt/c82e7f6f0ee8e112e9b0aaf3c27ab5b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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