Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -168,14 +168,17 @@ def process_text_to_audio(text, translatefrom="English", translateto="English"):
|
|
| 168 |
api_name="/t2st"
|
| 169 |
)
|
| 170 |
|
| 171 |
-
# The result is expected to be a tuple (audio_file_path, translated_text)
|
| 172 |
if not isinstance(result, tuple) or len(result) < 2:
|
| 173 |
raise ValueError("Unexpected result format from audio_client.predict")
|
| 174 |
|
| 175 |
audio_file_path, _ = result # Ignore the translated text for this function's purpose
|
| 176 |
|
| 177 |
-
#
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
except Exception as e:
|
| 180 |
print(f"Error processing text to audio: {e}")
|
| 181 |
return None
|
|
|
|
| 168 |
api_name="/t2st"
|
| 169 |
)
|
| 170 |
|
|
|
|
| 171 |
if not isinstance(result, tuple) or len(result) < 2:
|
| 172 |
raise ValueError("Unexpected result format from audio_client.predict")
|
| 173 |
|
| 174 |
audio_file_path, _ = result # Ignore the translated text for this function's purpose
|
| 175 |
|
| 176 |
+
# Assuming the audio file is stored in a publicly accessible location
|
| 177 |
+
# Append the base URL to the audio file path
|
| 178 |
+
base_url = "https://multitransformer-ayatonic.hf.space/"
|
| 179 |
+
audio_url = base_url + audio_file_path.lstrip("/home/user/app/") # Adjust the path as needed
|
| 180 |
+
|
| 181 |
+
return audio_url
|
| 182 |
except Exception as e:
|
| 183 |
print(f"Error processing text to audio: {e}")
|
| 184 |
return None
|