Spaces:
Runtime error
Runtime error
Update app.py
Browse files195 unmodified lines1961971981992002012022032042052062072081 unmodified line210211212213214215216217218219220221222223224225226227228229230231232233234235236195 unmodified linesdef 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:# Make a prediction request to the clientresult = client.predict("T2ST","text", # Since we are doing text-to-speechNone,None,input_text,1 unmodified linetarget_language,api_name="/run")# Initialize variablestranslated_text = ""audio_file_path = ""# Process the resultif result:for item in result:if isinstance(item, str):# Check if the item is a URL pointing to an audio fileif item.endswith('.mp3'):if not audio_file_path: # Store only the first audio file pathaudio_file_path = itemelse:# Concatenate the translated texttranslated_text += item + " "return audio_file_path, translated_text.strip()except Exception as e:return None, f"Error in text-to-speech conversion: {str(e)}"def process_image(image_input):# Initialize the Gradio client with the URL of the Gradio server195 unmodified lines1961971981992002012022032042052062072082092101 unmodified line212213214215216217218219220221222223224225226227228229230231232233234235236237238239195 unmodified linesdef convert_text_to_speech(input_text: str, source_language: str, target_language: str) -> tuple[str, str]:if not input_text or not source_language or not target_language:return None, "Invalid input parameters."client = Client("https://facebook-seamless-m4t.hf.space/--replicas/8cllp/")try:result = client.predict("T2ST","text",None,None,input_text,1 unmodified linetarget_language,api_name="/run")except Exception as e:return None, f"Error during prediction: {str(e)}"try:translated_text = ""audio_file_path = ""if result:for item in result:if isinstance(item, str):if item.endswith('.mp3') and not audio_file_path:audio_file_path = itemelse:translated_text += item + " "except Exception as e:return None, f"Error processing result: {str(e)}"if not audio_file_path:return None, "No audio file path found in the result."return audio_file_path, translated_text.strip()def process_image(image_input):# Initialize the Gradio client with the URL of the Gradio server
app.py+15-12