Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,14 @@ model = Wav2Vec2ForCTC.from_pretrained("boumehdi/wav2vec2-large-xlsr-moroccan-da
|
|
9 |
|
10 |
# Function to process the audio file and return transcription
|
11 |
def transcribe_audio(audio_file):
|
12 |
-
# Load and process the audio file
|
13 |
-
audio_input,
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Perform transcription
|
17 |
with torch.no_grad():
|
|
|
9 |
|
10 |
# Function to process the audio file and return transcription
|
11 |
def transcribe_audio(audio_file):
|
12 |
+
# Load and process the audio file with the correct sampling rate
|
13 |
+
audio_input, sampling_rate = torchaudio.load(audio_file, normalize=True)
|
14 |
+
|
15 |
+
# Make sure the audio input has the correct dimensions
|
16 |
+
audio_input = audio_input.squeeze() # Remove unnecessary dimensions
|
17 |
+
|
18 |
+
# Process the audio input for the model
|
19 |
+
input_values = processor(audio_input, sampling_rate=sampling_rate, return_tensors="pt").input_values
|
20 |
|
21 |
# Perform transcription
|
22 |
with torch.no_grad():
|