Spaces:
Runtime error
Runtime error
Update app.py
Browse files13 unmodified lines141516171819202122232413 unmodified linesforced_decoder_ids = processor.get_decoder_prompt_ids(language="italian", task="transcribe")# Custom preprocessing functiondef preprocess_audio(audio_data):# Apply any custom preprocessing to the audio data here if needed# Ensure that the input data is a valid format for the modelprocessed_data = processor(audio_data, return_tensors="pt", padding=True, truncation=True)return processed_data# Function to perform ASR on audio datadef transcribe_audio(audio_data):13 unmodified lines14151617181920212223242526272829303132333435363738394013 unmodified linesforced_decoder_ids = processor.get_decoder_prompt_ids(language="italian", task="transcribe")# Custom preprocessing functiondef preprocess_audio(audio_data, sampling_rate=16_000):# Ensure that the input data is a valid format for the model# Convert the audio data to a numpy array with a correct shaperaw_speech = np.asarray(audio_data, dtype=np.float32)# Pad or truncate the audio data to the required lengthif len(raw_speech) > processor.feature_extractor.max_len:raw_speech = raw_speech[:processor.feature_extractor.max_len]else:raw_speech = np.pad(raw_speech, (0, processor.feature_extractor.max_len - len(raw_speech)))# Process the audio data using the Whisper processorprocessed_data = processor(raw_speech,sampling_rate=sampling_rate,return_tensors="pt",padding=True,truncation=True)return processed_data.input_features# Function to perform ASR on audio datadef transcribe_audio(audio_data):
app.py+20-4