Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,38 +120,39 @@ def process_speech(input_language, audio_input):
|
|
| 120 |
except Exception as e :
|
| 121 |
return f"{e}"
|
| 122 |
|
| 123 |
-
def translate_text(input_text,
|
| 124 |
"""
|
| 125 |
Translate text from one language to another.
|
| 126 |
"""
|
| 127 |
try:
|
|
|
|
| 128 |
text_translation_result = seamless_client.predict(
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
api_name="/run_text_translation" # Adjust the API endpoint as needed
|
| 134 |
)
|
| 135 |
|
| 136 |
-
|
|
|
|
| 137 |
return translated_text
|
| 138 |
except Exception as e:
|
| 139 |
return f"An error occurred during translation: {e}"
|
| 140 |
|
| 141 |
-
def convert_text_to_speech(input_text,
|
| 142 |
"""
|
| 143 |
Convert text to speech in the specified language.
|
| 144 |
"""
|
| 145 |
try:
|
|
|
|
| 146 |
text_to_speech_result = seamless_client.predict(
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
api_name="/run_text_to_speech" # Adjust the API endpoint as needed
|
| 151 |
)
|
| 152 |
|
| 153 |
# Assuming the API returns a file path or similar identifier for the audio
|
| 154 |
-
audio_file = text_to_speech_result
|
| 155 |
return audio_file
|
| 156 |
except Exception as e:
|
| 157 |
return f"An error occurred during text-to-speech conversion: {e}"
|
|
|
|
| 120 |
except Exception as e :
|
| 121 |
return f"{e}"
|
| 122 |
|
| 123 |
+
def translate_text(input_text, source_language, target_language):
|
| 124 |
"""
|
| 125 |
Translate text from one language to another.
|
| 126 |
"""
|
| 127 |
try:
|
| 128 |
+
# Adjusting the parameters according to the successful API call
|
| 129 |
text_translation_result = seamless_client.predict(
|
| 130 |
+
"T2TT (Text to Text translation)",
|
| 131 |
+
source_language,
|
| 132 |
+
target_language,
|
| 133 |
+
input_text
|
|
|
|
| 134 |
)
|
| 135 |
|
| 136 |
+
# Assuming the API returns the translated text directly
|
| 137 |
+
translated_text = text_translation_result
|
| 138 |
return translated_text
|
| 139 |
except Exception as e:
|
| 140 |
return f"An error occurred during translation: {e}"
|
| 141 |
|
| 142 |
+
def convert_text_to_speech(input_text, language):
|
| 143 |
"""
|
| 144 |
Convert text to speech in the specified language.
|
| 145 |
"""
|
| 146 |
try:
|
| 147 |
+
# Adjusting the parameters according to the successful API call
|
| 148 |
text_to_speech_result = seamless_client.predict(
|
| 149 |
+
"T2ST (Text to Speech translation)",
|
| 150 |
+
language,
|
| 151 |
+
input_text
|
|
|
|
| 152 |
)
|
| 153 |
|
| 154 |
# Assuming the API returns a file path or similar identifier for the audio
|
| 155 |
+
audio_file = text_to_speech_result
|
| 156 |
return audio_file
|
| 157 |
except Exception as e:
|
| 158 |
return f"An error occurred during text-to-speech conversion: {e}"
|