-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfw_scripty.py
More file actions
54 lines (41 loc) · 1.44 KB
/
fw_scripty.py
File metadata and controls
54 lines (41 loc) · 1.44 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import time
import torch
import numpy as np
from faster_whisper import WhisperModel
def check_environment():
# Check if CUDA is available
cuda_available = torch.cuda.is_available()
if cuda_available:
cuda_version = torch.version.cuda
print(f"CUDA is available. Version: {cuda_version}")
else:
print("CUDA is not available.")
# Print the versions of the main libraries
print(f"PyTorch version: {torch.__version__}")
print(f"NumPy version: {np.__version__}")
print("Using faster-whisper for transcription.")
def scripty():
# Load the faster-whisper model
print("Before loading model")
model = WhisperModel("large-v3", device="cuda" if torch.cuda.is_available() else "cpu")
print("After loading model")
# Check if the model is loaded
if model is not None:
print("Model loaded successfully!")
else:
print("Model failed to load.")
# Load and process the audio file
segments, info = model.transcribe("samples/german.mp3")
# Decode the audio and measure the time taken
start_time = time.time()
# Collect the recognized text
recognized_text = ""
for segment in segments:
recognized_text += segment.text
end_time = time.time()
print(f"Decoding took {end_time - start_time:.2f} seconds")
# Print the recognized text
print("Text: " + recognized_text)
if __name__ == "__main__":
check_environment()
scripty()