fastinom commited on
Commit
80fe41f
1 Parent(s): 5e9f513

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -69,6 +69,38 @@ Users (both direct and downstream) should be made aware of the risks, biases and
69
 
70
  Use the code below to get started with the model.
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  ## Training Details
74
 
 
69
 
70
  Use the code below to get started with the model.
71
 
72
+
73
+ ### Running the model
74
+ <details>
75
+ <summary> Click to expand </summary>
76
+ ```python
77
+
78
+ !pip install transformers datasets torchaudio
79
+
80
+ from transformers import Wav2Vec2ForCTC, Wav2Vec2Processor
81
+ import torch
82
+ import torchaudio
83
+
84
+ model_id = "fastinom/ASR_fassy"
85
+ model = Wav2Vec2ForCTC.from_pretrained(model_id)
86
+ processor = Wav2Vec2Processor.from_pretrained(model_id)
87
+
88
+ def load_audio(file_path):
89
+ speech_array, sampling_rate = torchaudio.load(file_path)
90
+ resampler = torchaudio.transforms.Resample(sampling_rate, 16000)
91
+ speech = resampler(speech_array).squeeze().numpy()
92
+ return speech
93
+ audio_file = "/content/drive/MyDrive/recordings/wavefiles/1.wa"#YOUR AUDIO PATH
94
+ speech = load_audio(audio_file)
95
+
96
+ inputs = processor(speech, sampling_rate=16000, return_tensors="pt", padding=True)
97
+ with torch.no_grad():
98
+ logits = model(inputs.input_values).logits
99
+ predicted_ids = torch.argmax(logits, dim=-1)
100
+ transcription = processor.batch_decode(predicted_ids)
101
+ print(transcription[0])
102
+ ```
103
+ </details>
104
 
105
  ## Training Details
106