Spaces:
Runtime error
Runtime error
Update app.py
Browse files138 unmodified lines139140141142142143144145144145146147148149150151152153154155156157158159160161162163164165166167215 unmodified lines38338438536838638738844 unmodified lines433434435419436437438439138 unmodified lines api_name="/run" # API name )
# Check if result contains files and select the first one # Check if result contains files if isinstance(result, list) and len(result) > 1: # Select the first audio file from the result original_audio_file = result[1] # Assuming the first element is the audio file downloaded_files = [] for file_path in result[1:]: if os.path.isfile(file_path): # Download the file downloaded_files.append(file_path) else: print(f"Path is not a file: {file_path}")
if downloaded_files: # Process only the first file original_audio_file = downloaded_files[0] new_file_name = f"audio_output_{uuid.uuid4()}.wav" new_file_path = os.path.join(os.path.dirname(original_audio_file), new_file_name) os.rename(original_audio_file, new_file_path) return new_file_path else: return "No valid audio files were downloaded."
else: return "No audio files received from the API." # Iterate over the result to find the last text item translated_text = "" for item in result:215 unmodified lines markdown_output = "" image_text = "" translated_text = "" audio_file_path = "" audio_output = "" # Debugging print statement print(f"Image Input Type: {type(image_input)}, Audio Input Type: {type(audio_input)}")44 unmodified lines
# Convert translated text to speech and get both audio file and text target_language = "English" # Set the target language for the speech audio_file_path, translated_text = convert_text_to_speech(final_response, target_language, input_language) audio_output, translated_text = convert_text_to_speech(final_response, target_language, input_language) # Evaluate hallucination hallucination_label = evaluate_hallucination(final_response, summary)app.py+22-5