Update app.py
Browse files
app.py
CHANGED
|
@@ -57,17 +57,17 @@ class SpeechClassifier(nn.Module, PyTorchModelHubMixin):
|
|
| 57 |
|
| 58 |
# Prepare data function
|
| 59 |
def prepare_data(audio_data, sampling_rate, model_checkpoint="openai/whisper-base"):
|
| 60 |
-
|
| 61 |
# Resample audio data to 16000 Hz
|
| 62 |
audio_data_resampled = librosa.resample(audio_data, orig_sr=sampling_rate, target_sr=16000)
|
| 63 |
|
| 64 |
# Initialize the feature extractor
|
| 65 |
feature_extractor = WhisperFeatureExtractor.from_pretrained(model_checkpoint)
|
| 66 |
-
|
| 67 |
-
# Use Dataset class
|
| 68 |
dataset = SpeechInferenceDataset([{"audio": {"array": audio_data_resampled, "sampling_rate": 16000}}],
|
| 69 |
text_processor=feature_extractor)
|
| 70 |
-
|
| 71 |
return dataset
|
| 72 |
|
| 73 |
|
|
@@ -119,5 +119,5 @@ with gr.Blocks() as demo:
|
|
| 119 |
outputs=gr.Textbox(label="Prediction")
|
| 120 |
)
|
| 121 |
|
| 122 |
-
# Launch the demo
|
| 123 |
-
demo.launch(
|
|
|
|
| 57 |
|
| 58 |
# Prepare data function
|
| 59 |
def prepare_data(audio_data, sampling_rate, model_checkpoint="openai/whisper-base"):
|
| 60 |
+
|
| 61 |
# Resample audio data to 16000 Hz
|
| 62 |
audio_data_resampled = librosa.resample(audio_data, orig_sr=sampling_rate, target_sr=16000)
|
| 63 |
|
| 64 |
# Initialize the feature extractor
|
| 65 |
feature_extractor = WhisperFeatureExtractor.from_pretrained(model_checkpoint)
|
| 66 |
+
|
| 67 |
+
# Use Dataset class
|
| 68 |
dataset = SpeechInferenceDataset([{"audio": {"array": audio_data_resampled, "sampling_rate": 16000}}],
|
| 69 |
text_processor=feature_extractor)
|
| 70 |
+
|
| 71 |
return dataset
|
| 72 |
|
| 73 |
|
|
|
|
| 119 |
outputs=gr.Textbox(label="Prediction")
|
| 120 |
)
|
| 121 |
|
| 122 |
+
# Launch the demo
|
| 123 |
+
demo.launch()
|