Installazuione per tutto

sh
sudo apt-get update
sudo apt -y upgrade
sudo apt install ffmpeg

sudo apt-get install python3-pip
sudo pip3 install -U setuptools-rust
sudo pip3 install -U openai-whisper

Codice Python

python
import whisper
import torch

# Check if GPU is available
device = "cuda" if torch.cuda.is_available() else "cpu"

# Load the model on the specified device
model = whisper.load_model("medium", device=device)

# Transcribe the audio file
result = model.transcribe("test.mp3")

# Print the transcribed text
print(result["text"])