Update README.md
Browse files
README.md
CHANGED
@@ -15,44 +15,4 @@ this model trained on validation segment of data for one epoch with 0.05 loss an
|
|
15 |
|
16 |
how to use the model in colab:
|
17 |
|
18 |
-
|
19 |
-
pip install torch torchaudio transformers librosa gradio
|
20 |
-
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
21 |
-
import torch
|
22 |
-
|
23 |
-
#Load your fine-tuned Whisper model and processor
|
24 |
-
model_name = "hackergeek98/tinyyyy_whisper"
|
25 |
-
processor = WhisperProcessor.from_pretrained(model_name)
|
26 |
-
model = WhisperForConditionalGeneration.from_pretrained(model_name)
|
27 |
-
|
28 |
-
#Force the model to transcribe in Persian
|
29 |
-
model.config.forced_decoder_ids = processor.get_decoder_prompt_ids(language="fa", task="transcribe")
|
30 |
-
|
31 |
-
#Move model to GPU if available
|
32 |
-
device = "cuda" if torch.cuda.is_available() else "cpu"
|
33 |
-
model.to(device)
|
34 |
-
import librosa
|
35 |
-
|
36 |
-
def transcribe_audio(audio_file):
|
37 |
-
# Load audio file using librosa (supports multiple formats)
|
38 |
-
audio_data, sampling_rate = librosa.load(audio_file, sr=16000) # Resample to 16kHz
|
39 |
-
|
40 |
-
# Preprocess the audio
|
41 |
-
inputs = processor(audio_data, sampling_rate=sampling_rate, return_tensors="pt").input_features.to(device)
|
42 |
-
|
43 |
-
# Generate transcription
|
44 |
-
with torch.no_grad():
|
45 |
-
predicted_ids = model.generate(inputs)
|
46 |
-
|
47 |
-
# Decode the transcription
|
48 |
-
transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)[0]
|
49 |
-
return transcription
|
50 |
-
from google.colab import files
|
51 |
-
|
52 |
-
#Upload an audio file
|
53 |
-
uploaded = files.upload()
|
54 |
-
audio_file = list(uploaded.keys())[0]
|
55 |
-
|
56 |
-
#Transcribe the audio
|
57 |
-
transcription = transcribe_audio(audio_file)
|
58 |
-
print("Transcription:", transcription)
|
|
|
15 |
|
16 |
how to use the model in colab:
|
17 |
|
18 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|