Last active
January 8, 2024 12:17
-
-
Save arturbosch/7487408dae66b9343b20740fab7852ec to your computer and use it in GitHub Desktop.
whisper speech-to-text
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
from pathlib import Path | |
import whisper | |
# CHANGE THE MODEL HERE: use "base" or "medium" | |
MODEL_NAME = "base" | |
MODEL = whisper.load_model(MODEL_NAME) | |
with open(MODEL_NAME + ".txt", "a", encoding="utf-8") as result_file: | |
for path in sorted( | |
Path("wav").glob("*.wav"), key=lambda p: int(p.stem.replace(".wav", "")) | |
): | |
print("processing " + str(path) + " ...") | |
result = MODEL.transcribe(str(path), fp16=False, language="English") | |
transcript = result["text"].strip() | |
print(transcript) | |
result_file.write(transcript) | |
result_file.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment