Update app.py
Browse files
app.py
CHANGED
|
@@ -68,9 +68,14 @@ def format_transcript(transcript):
|
|
| 68 |
|
| 69 |
def transcribe_audio(audio_file):
|
| 70 |
try:
|
| 71 |
-
# Load and
|
| 72 |
-
audio_input,
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
# Generate token ids
|
| 76 |
predicted_ids = model.generate(input_features)
|
|
|
|
| 68 |
|
| 69 |
def transcribe_audio(audio_file):
|
| 70 |
try:
|
| 71 |
+
# Load and resample the audio to 16000 Hz
|
| 72 |
+
audio_input, _ = librosa.load(audio_file, sr=16000)
|
| 73 |
+
|
| 74 |
+
# Convert to float32 numpy array
|
| 75 |
+
audio_input = audio_input.astype(np.float32)
|
| 76 |
+
|
| 77 |
+
# Prepare the input features
|
| 78 |
+
input_features = processor(audio_input, sampling_rate=16000, return_tensors="pt").input_features.to(device)
|
| 79 |
|
| 80 |
# Generate token ids
|
| 81 |
predicted_ids = model.generate(input_features)
|