|
import os |
|
|
|
from managers.file_manager import FileManager |
|
from tools.chess_board_recognition_tool import ChessBoardRecognitionTool |
|
from tools.convert_audio_to_text_tool import ConvertAudioToTextTool |
|
from tools.convert_image_to_text_tool import ConvertImageToTextTool |
|
from tools.fetch_url_content_tool import FetchURLContentTool |
|
|
|
|
|
def test_fetch_url(): |
|
print("Test FetchURLContentTool...") |
|
tool = FetchURLContentTool() |
|
url = "https://upload.wikimedia.org/wikipedia/commons/3/3c/Shaki_waterfall.jpg" |
|
path = tool.forward(url) |
|
print(f"Downloaded in: {path}") |
|
FileManager.cleanup_file(path) |
|
|
|
def test_transcribe_audio(): |
|
print("Test TranscribeAudioTool...") |
|
tool = ConvertAudioToTextTool() |
|
sample_audio = "data/sample_audio.mp3" |
|
if not os.path.exists(sample_audio): |
|
print("File not found: data/sample_audio.mp3") |
|
return |
|
text = tool.forward(sample_audio) |
|
print(f"Result:\n{text}") |
|
|
|
def test_transcribe_image(): |
|
print("Test TranscribeImageTool...") |
|
tool = ConvertImageToTextTool() |
|
sample_audio = "data/sample_image.jpg" |
|
if not os.path.exists(sample_audio): |
|
print("File not found: data/sample_image.jpg") |
|
return |
|
text = tool.forward(sample_audio) |
|
print(f"Result:\n{text}") |
|
|
|
def test_chess_board_recognition_image(): |
|
print("Test CaptionImageTool...") |
|
tool = ChessBoardRecognitionTool() |
|
sample_image = "data/sample_image.jpg" |
|
if not os.path.exists(sample_image): |
|
print("File not found: data/sample_image.jpg") |
|
return |
|
caption = tool.forward(sample_image) |
|
print(f"Result:\n{caption}") |
|
|
|
def run_all_tests(): |
|
print("\n--- START TEST ---\n") |
|
test_fetch_url() |
|
test_transcribe_audio() |
|
test_transcribe_image() |
|
|
|
print("\n--- ALL TESTS COMPLETED ---\n") |
|
|
|
if __name__ == "__main__": |
|
run_all_tests() |
|
|