Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -33,14 +33,14 @@ async def transcribe_audio(request: Request):
|
|
33 |
# Convert binary data to a file-like object
|
34 |
audio_file = io.BytesIO(audio_data)
|
35 |
# # Load the audio file using pydub
|
36 |
-
|
37 |
# # Process the audio array
|
38 |
# input_features = processor(audio_array, sampling_rate=sampling_rate, return_tensors="pt").input_features
|
39 |
# # Generate token ids
|
40 |
# predicted_ids = model.generate(input_features)
|
41 |
# # Decode token ids to text
|
42 |
# transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
43 |
-
transcription = pipe(
|
44 |
# Print the transcription
|
45 |
print(transcription)
|
46 |
print(transcription[0]) # Display the transcriptiontry:
|
|
|
33 |
# Convert binary data to a file-like object
|
34 |
audio_file = io.BytesIO(audio_data)
|
35 |
# # Load the audio file using pydub
|
36 |
+
audio_array, sampling_rate = librosa.load(audio_file, sr=16000)
|
37 |
# # Process the audio array
|
38 |
# input_features = processor(audio_array, sampling_rate=sampling_rate, return_tensors="pt").input_features
|
39 |
# # Generate token ids
|
40 |
# predicted_ids = model.generate(input_features)
|
41 |
# # Decode token ids to text
|
42 |
# transcription = processor.batch_decode(predicted_ids, skip_special_tokens=True)
|
43 |
+
transcription = pipe(audio_array,generate_kwargs = {"task":"transcribe", "language":"<|ar|>"})
|
44 |
# Print the transcription
|
45 |
print(transcription)
|
46 |
print(transcription[0]) # Display the transcriptiontry:
|