I’m a AI undergraduate and an AI enthusiast, working on machine learning projects and open-source contributions.
I enjoy exploring AI pipelines, natural language processing, and building tools that make development easier.
This model is a fine-tuned version of
openai/whisper-small on the Sinhala CSV + FLACs dataset.
It achieves the following results on the evaluation set:
Can be used for Sinhala speech to text conversions. Make sure to input noise low audio to the model, to get the best outcome.
Trained on the custom dataset -
seniruk/sinscribe-sinhala-stt
Trained on above final dataset with 2 epochs on a device with below spec for 41:00:59 hours
1import torchaudio
2from transformers import pipeline
3import torch
4
5device = 0 if torch.cuda.is_available() else -1
6
7from transformers import pipeline
8
9pipe = pipeline("automatic-speech-recognition", model="seniruk/whisper-small-si",device=device)
10
11def transcribe(audio_path):
12 if audio_path is None:
13 return "No audio received. Please record something."
14
15 waveform, sample_rate = torchaudio.load(audio_path)
16
17 if waveform.shape[0] > 1:
18 waveform = waveform.mean(dim=0, keepdim=True)
19
20 array = waveform.squeeze().numpy()
21
22 result = pipe({"array": array, "sampling_rate": sample_rate})
23 return result["text"]
24
25result= transcribe("audio.wav")
26print(result)
1import torchaudio
2from transformers import pipeline
3import gradio as gr
4import torch
5
6# === Setup ===
7device = 0 if torch.cuda.is_available() else -1
8MAX_DURATION_SECONDS = 30 # Limit audio length to 30 seconds
9
10# Load fine-tuned Whisper pipeline
11pipe = pipeline(
12 "automatic-speech-recognition",
13 model="seniruk/whisper-small-si",
14 device=device
15)
16
17def transcribe(audio_path):
18 try:
19 if audio_path is None:
20 return "No audio received. Please record or upload a file."
21
22 # Load and prepare audio
23 waveform, sample_rate = torchaudio.load(audio_path)
24
25 # Convert to mono
26 if waveform.shape[0] > 1:
27 waveform = waveform.mean(dim=0, keepdim=True)
28
29 # Duration check
30 duration = waveform.shape[1] / sample_rate
31 if duration > MAX_DURATION_SECONDS:
32 return f"Audio too long ({duration:.1f}s). Please use a clip shorter than {MAX_DURATION_SECONDS}s."
33
34 # Convert to numpy array
35 array = waveform.squeeze().numpy()
36
37 # Run inference
38 result = pipe({"array": array, "sampling_rate": sample_rate})
39
40 return result.get("text", "No transcription returned.")
41
42 except Exception as e:
43 return f"Error during transcription: {e}"
44
45
46# === Gradio Interface ===
47iface = gr.Interface(
48 fn=transcribe,
49 inputs=gr.Audio(sources=["microphone", "upload"], type="filepath", label="Record or Upload Audio"),
50 outputs=gr.Textbox(label="Transcription"),
51 title="Whisper Small Sinhala (GPU/CPU)",
52 description=(
53 "Sinhala speech-to-text demo using a fine-tuned Whisper Small model(Sinscribe) "
54 "Supports microphone recording or file upload (max 30 seconds)"
55 ),
56)
57
58iface.launch()