-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenrator.py
More file actions
27 lines (26 loc) · 928 Bytes
/
Copy pathgenrator.py
File metadata and controls
27 lines (26 loc) · 928 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 os
import whisper
from whisper.utils import get_writer
import sys
import warnings
warnings.filterwarnings("ignore")
# Get the path to the audio file
if (len(sys.argv) == 2):
audio_file_path = sys.argv[1]
# Check if Whisper AI has access to the file
if os.access(audio_file_path, os.R_OK):
# Whisper AI has access to the file
print("Whisper AI has access to the file.")
model = whisper.load_model("medium.en")
# Transcribe the audio file
result = model.transcribe(audio_file_path)
# Print the transcription
srt_writer = get_writer("srt", "./str/")
srt_writer(result, audio_file_path)
json_writer = get_writer("json", "./json/")
json_writer(result, audio_file_path)
else:
# Whisper AI does not have access to the file
print("Whisper AI does not have access to the file.")
else:
print("need more argument")