Spaces:
Runtime error
Runtime error
Update app.py
Browse files119 unmodified lines120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157119 unmodified linesexcept Exception as e :return f"{e}"def translate_text(input_text, input_language):"""Translate text from one language to another."""try:text_translation_result = seamless_client.predict(task="T2TT (Text to Text translation)",input_text=input_text,source_language="Auto-detect", # If auto-detection is supportedtarget_language=input_language,api_name="/run_text_translation" # Adjust the API endpoint as needed)translated_text = text_translation_result['translated_text']return translated_textexcept Exception as e:return f"An error occurred during translation: {e}"def convert_text_to_speech(input_text, input_language):"""Convert text to speech in the specified language."""try:text_to_speech_result = seamless_client.predict(task="T2ST (Text to Speech translation)",input_text=input_text,language=input_language,api_name="/run_text_to_speech" # Adjust the API endpoint as needed)# Assuming the API returns a file path or similar identifier for the audioaudio_file = text_to_speech_result['audio_file']return audio_fileexcept Exception as e:return f"An error occurred during text-to-speech conversion: {e}"119 unmodified lines120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158119 unmodified linesexcept Exception as e :return f"{e}"def translate_text(input_text, source_language, target_language):"""Translate text from one language to another."""try:# Adjusting the parameters according to the successful API calltext_translation_result = seamless_client.predict("T2TT (Text to Text translation)",source_language,target_language,input_text)# Assuming the API returns the translated text directlytranslated_text = text_translation_resultreturn translated_textexcept Exception as e:return f"An error occurred during translation: {e}"def convert_text_to_speech(input_text, language):"""Convert text to speech in the specified language."""try:# Adjusting the parameters according to the successful API calltext_to_speech_result = seamless_client.predict("T2ST (Text to Speech translation)",language,input_text)# Assuming the API returns a file path or similar identifier for the audioaudio_file = text_to_speech_resultreturn audio_fileexcept Exception as e:return f"An error occurred during text-to-speech conversion: {e}"
app.py+14-13