Spaces:
Runtime error
Runtime error
Update app.py
Browse files155 unmodified lines1561571581591601611624 unmodified lines167168169170171172173174175176177178179180181182183184185186187188189155 unmodified lines# Initialize variablestranslated_text = ""new_file_path = ""# Process each item in the resultfor item in result:4 unmodified lines# Assign the first non-URL string as the translated textif 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):# Initialize the Gradio client with the URL of the Gradio serverclient = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")155 unmodified lines1561571581591601611624 unmodified lines167168169170171172173174175176177178179180181182155 unmodified lines# Initialize variablestranslated_text = ""audio_file_path = ""# Process each item in the resultfor item in result:4 unmodified lines# Assign the first non-URL string as the translated textif not translated_text:translated_text = itemelif isinstance(item, tuple) and len(item) == 2:# Assuming the item is a tuple containing sample rate and audio dataaudio_file_path = save_audio(item) # Save the audio filebreakreturn audio_file_path, translated_textexcept Exception as e:return f"Error in text-to-speech conversion: {str(e)}", ""def process_image(image_input):# Initialize the Gradio client with the URL of the Gradio serverclient = Client("https://adept-fuyu-8b-demo.hf.space/--replicas/pqjvl/")
app.py+7-14