Views
No views yet
"Which millet variety is suitable for clay soil?"
The goal is to build a robust speech-to-text model adapted to these accents and vocabulary.
Note: This repository contains only the speech transcription model.
For the full pipeline (ASR + classifiers), see the dedicated repository:
👉 Kadidiatou131313/agri-assistant-pipeline
jonatasgrosman/wav2vec2-large-xlsr-53-french] on a custom dataset of agricultural voice queries from Senegal.1import librosa
2import torch
3from transformers import AutoModelForCTC, Wav2Vec2Processor
4DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
5
6# Load model and processor
7model = AutoModelForCTC.from_pretrained("Kadidiatou131313/wav2vec2-fr-agriculture").to(DEVICE)
8processor = Wav2Vec2Processor.from_pretrained("Kadidiatou131313/wav2vec2-fr-agriculture")
9
10def transcribe(audio_path: str) -> str:
11 # Load audio in mono, 16kHz
12 wav, sr = librosa.load(audio_path, sr=16000, mono=True)
13
14 # Prepare input
15 inputs = processor(wav, sampling_rate=16000, return_tensors="pt", padding=True)
16 with torch.no_grad():
17 logits = model(inputs.input_values.to(DEVICE)).logits
18 pred_ids = torch.argmax(logits, dim=-1)
19 # Decode to text
20 text = processor.decode(pred_ids[0])
21 return text.strip()| Training Loss | Epoch | Step | Validation Loss | WER |
|---|---|---|---|---|
| 3.9756 | 2.27 | 100 | 3.0001 | 1.0 |
| 3.1017 | 4.54 | 200 | 2.7959 | 1.0 |
| 1.0941 | 6.82 | 300 | 0.6419 | 0.4625 |
| 0.4260 | 9.09 | 400 | 0.4922 | 0.295 |
| 0.2826 | 11.36 | 500 | 0.4858 | 0.2375 |
| 0.2694 | 13.63 | 600 | 0.4439 | 0.215 |
| 0.1746 | 15.90 | 700 | 0.4631 | 0.2025 |
| 0.1464 | 18.18 | 800 | 0.5627 | 0.185 |
| 0.1219 | 20.45 | 900 | 0.5898 | 0.1875 |
| 0.0924 | 22.72 | 1000 | 0.6369 | 0.2025 |
| 0.0981 | 25.0 | 1100 | 0.5955 | 0.19 |
"Quelle variété de mil est adaptée à un sol argileux ?"
jonatasgrosman/wav2vec2-large-xlsr-53-french] sur un jeu de données personnalisé de requêtes vocales agricoles sénégalaises.1import librosa
2import torch
3from transformers import AutoModelForCTC, Wav2Vec2Processor
4DEVICE = "cuda" if torch.cuda.is_available() else "cpu"
5# Charger modèle et processor
6model = AutoModelForCTC.from_pretrained("Kadidiatou131313/wav2vec2-fr-agriculture").to(DEVICE)
7processor = Wav2Vec2Processor.from_pretrained("Kadidiatou131313/wav2vec2-fr-agriculture")
8def transcrire(audio_path: str) -> str:
9 # Charger l’audio en mono 16kHz
10 wav, sr = librosa.load(audio_path, sr=16000, mono=True)
11 # Préparer l’entrée
12 inputs = processor(wav, sampling_rate=16000, return_tensors="pt", padding=True)
13 with torch.no_grad():
14 logits = model(inputs.input_values.to(DEVICE)).logits
15 pred_ids = torch.argmax(logits, dim=-1)
16 # Décodage en texte
17 text = processor.decode(pred_ids[0])
18 return text.strip()| Training Loss | Époque | Step | Validation Loss | WER |
|---|---|---|---|---|
| 3.9756 | 2.27 | 100 | 3.0001 | 1.0 |
| 3.1017 | 4.54 | 200 | 2.7959 | 1.0 |
| 1.0941 | 6.82 | 300 | 0.6419 | 0.4625 |
| 0.4260 | 9.09 | 400 | 0.4922 | 0.295 |
| 0.2826 | 11.36 | 500 | 0.4858 | 0.2375 |
| 0.2694 | 13.63 | 600 | 0.4439 | 0.215 |
| 0.1746 | 15.90 | 700 | 0.4631 | 0.2025 |
| 0.1464 | 18.18 | 800 | 0.5627 | 0.185 |
| 0.1219 | 20.45 | 900 | 0.5898 | 0.1875 |
| 0.0924 | 22.72 | 1000 | 0.6369 | 0.2025 |
| 0.0981 | 25.0 | 1100 | 0.5955 | 0.19 |