Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -153,7 +153,11 @@ def convert_text_to_speech(input_text: str, source_language: str, target_languag
|
|
| 153 |
target_language,
|
| 154 |
api_name="/run",
|
| 155 |
)
|
| 156 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
# Initialize variables
|
| 158 |
translated_text = ""
|
| 159 |
audio_file_path = ""
|
|
@@ -172,10 +176,13 @@ def convert_text_to_speech(input_text: str, source_language: str, target_languag
|
|
| 172 |
audio_file_path = save_audio(item) # Save the audio file
|
| 173 |
break
|
| 174 |
|
|
|
|
|
|
|
|
|
|
| 175 |
return audio_file_path, translated_text
|
| 176 |
|
| 177 |
except Exception as e:
|
| 178 |
-
return f"Error in text-to-speech conversion: {str(e)}"
|
| 179 |
|
| 180 |
def process_image(image_input):
|
| 181 |
# Initialize the Gradio client with the URL of the Gradio server
|
|
|
|
| 153 |
target_language,
|
| 154 |
api_name="/run",
|
| 155 |
)
|
| 156 |
+
|
| 157 |
+
# Check if the result is valid
|
| 158 |
+
if not result:
|
| 159 |
+
raise ValueError("No result returned from text-to-speech service")
|
| 160 |
+
|
| 161 |
# Initialize variables
|
| 162 |
translated_text = ""
|
| 163 |
audio_file_path = ""
|
|
|
|
| 176 |
audio_file_path = save_audio(item) # Save the audio file
|
| 177 |
break
|
| 178 |
|
| 179 |
+
if not audio_file_path:
|
| 180 |
+
raise ValueError("No audio file path returned from text-to-speech service")
|
| 181 |
+
|
| 182 |
return audio_file_path, translated_text
|
| 183 |
|
| 184 |
except Exception as e:
|
| 185 |
+
return "", f"Error in text-to-speech conversion: {str(e)}"
|
| 186 |
|
| 187 |
def process_image(image_input):
|
| 188 |
# Initialize the Gradio client with the URL of the Gradio server
|