-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtranscriber.py
More file actions
28 lines (19 loc) · 755 Bytes
/
transcriber.py
File metadata and controls
28 lines (19 loc) · 755 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import whisper
import warnings
from tqdm import tqdm
import os
from dotenv import load_dotenv
load_dotenv()
MODEL_VERSION = os.getenv("WHISPER_MODEL") # default is "base"
warnings.filterwarnings("ignore", category=UserWarning, message="FP16 is not supported on CPU")
tqdm.write(f"Loading Whisper {MODEL_VERSION} model...")
model = whisper.load_model(MODEL_VERSION)
def transcribe(audio_file):
tqdm.write(f"Transcribing using {MODEL_VERSION} model...")
result = model.transcribe(audio_file)
return(result['text'])
def save_transcription_as_text_file(transcription):
filename = "transcription.txt"
with open(filename, 'w') as file:
file.write(transcription)
tqdm.write(f"Transcription has been saved to {filename}")