Spaces:
Sleeping
Sleeping
Update predictions.py
Browse files- predictions.py +14 -3
predictions.py
CHANGED
@@ -23,8 +23,19 @@ def get_predictions(uploaded_image):
|
|
23 |
|
24 |
# Summarize predictions
|
25 |
text = summarize_predictions_natural_language(pipeline_output)
|
|
|
26 |
|
27 |
-
|
28 |
-
narrated_text = tts_pipe(
|
|
|
|
|
29 |
|
30 |
-
return processed_image,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
# Summarize predictions
|
25 |
text = summarize_predictions_natural_language(pipeline_output)
|
26 |
+
corrected_text = correct_text(text)
|
27 |
|
28 |
+
# Generate audio from text
|
29 |
+
narrated_text = tts_pipe(corrected_text)
|
30 |
+
audio_data = narrated_text["audio"][0]
|
31 |
+
sample_rate = narrated_text["sampling_rate"]
|
32 |
|
33 |
+
return processed_image,corrected_text, (sample_rate, audio_data)
|
34 |
+
|
35 |
+
|
36 |
+
def correct_text(text):
|
37 |
+
# Rule-based correction
|
38 |
+
# Example: "there are one horse" -> "there is one horse"
|
39 |
+
if "there are one" in text:
|
40 |
+
text = text.replace("there are one", "there is one")
|
41 |
+
return text
|