Spaces:
Runtime error
Runtime error
Update app.py
Browse files139 unmodified lines1401411421431441451461471481491501511521531541551561571581591601618 unmodified lines170171172173174175176177178179180181182183184185186187188189190191192139 unmodified linesreturn f"{e}"def convert_text_to_speech(input_text: str, source_language: str, target_language: str) -> tuple[str, str]:client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")try:result = client.predict("T2ST", # Task"", # Audio sourceNone, # Input audio micNone, # Input audio fileinput_text, # Input textsource_language, # Source languagetarget_language, # Target languageapi_name="/run", # API endpoint)# Initialize variablestranslated_text = ""new_file_path = ""8 unmodified linesif not translated_text:translated_text = itemelif os.path.isdir(item):# Process the directory to find the first audio filefor file in os.listdir(item):file_path = os.path.join(item, file)if os.path.isfile(file_path) and file_path.endswith('.wav'):new_file_name = f"audio_output_{uuid.uuid4()}.wav"new_file_path = os.path.join(os.path.dirname(file_path), new_file_name)os.rename(file_path, new_file_path)break # Stop after finding the first audio fileif new_file_path:break # Exit if an audio file has been processedreturn new_file_path, translated_textexcept Exception as e:return f"Error in text-to-speech conversion: {str(e)}", ""def process_image(image_input):139 unmodified lines1401411421431441451461471481491501511521531541551561571581591601611621638 unmodified lines172173174175176177178179180181182183184185186187188189190191139 unmodified linesreturn f"{e}"import osimport uuiddef convert_text_to_speech(input_text: str, source_language: str, target_language: str) -> tuple[str, str]:client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")try:result = client.predict(task_name="T2ST",audio_source="",input_audio_mic=None,input_audio_file=None,input_text=input_text,source_language=source_language,target_language=target_language,api_name="/run",)# Initialize variablestranslated_text = ""new_file_path = ""8 unmodified linesif not translated_text:translated_text = itemelif os.path.isdir(item):# Find the first MP3 file in the directoryfor file in os.listdir(item):file_path = os.path.join(item, file)if os.path.isfile(file_path) and file_path.endswith('.mp3'):# Return the path of the MP3 file directly without renamingnew_file_path = file_pathbreakif new_file_path:breakreturn new_file_path, translated_textexcept Exception as e:return f"Error in text-to-speech conversion: {str(e)}", ""def process_image(image_input):
app.py+17-18