Spaces:
Runtime error
Runtime error
Update app.py
Browse files119 unmodified lines12012112212312412511 unmodified lines137138139140141142143144145146147119 unmodified linesexcept Exception as e :return f"{e}"def convert_text_to_speech(input_text, target_language):"""Convert text to speech in the specified language and return both the audio file path and the input text.11 unmodified lines)audio_file = text_to_speech_result[1] # Assuming the audio file path is in the second positionreturn audio_file, input_textexcept Exception as e:return f"An error occurred during text-to-speech conversion: {e}", input_textdef save_image(image_input, output_dir="saved_images"):if not os.path.exists(output_dir):os.makedirs(output_dir)119 unmodified lines12012112212312412512612711 unmodified lines139140141142143144145146147148149150151152153154155156157158119 unmodified linesexcept Exception as e :return f"{e}"import osdef convert_text_to_speech(input_text, target_language):"""Convert text to speech in the specified language and return both the audio file path and the input text.11 unmodified lines)audio_file = text_to_speech_result[1] # Assuming the audio file path is in the second position# Shorten the file name to 12 charactersmax_length = 12 # Maximum file name lengthdir_name, file_name = os.path.split(audio_file)if len(file_name) > max_length:# Keep the file extension if presentfile_extension = os.path.splitext(file_name)[1]file_name = file_name[:max_length - len(file_extension)] + file_extensionaudio_file = os.path.join(dir_name, file_name)return audio_file, input_textexcept Exception as e:return f"An error occurred during text-to-speech conversion: {e}", input_textdef save_image(image_input, output_dir="saved_images"):if not os.path.exists(output_dir):os.makedirs(output_dir)
app.py+12-1