-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
87 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
["E", "D#", "E", "D#", "E", "B", "D", "C", "A"] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,69 @@ | ||
"""Set of tests for the sounds module.""" | ||
import os | ||
import unittest | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from artbox.sounds import Sound | ||
|
||
TMP_PATH = Path("/tmp/artbox") | ||
TEST_DATA_DIR = Path(__file__).parent / "data" | ||
|
||
os.makedirs(TMP_PATH, exist_ok=True) | ||
|
||
@pytest.mark.fixture | ||
def sound(): | ||
"""Create a fixture for the Sound object.""" | ||
return Sound() | ||
|
||
def test_notes_to_audio(): | ||
"""Test the extraction of notes from mp3 file.""" | ||
mp3_path = TMP_PATH / "set1.mp3" | ||
notes_path = TEST_DATA_DIR / "notes" / "set1.txt" | ||
|
||
@pytest.mark.skip | ||
def test_extract(sound): | ||
"""Test the extraction audio from a video.""" | ||
videos_path = TMP_PATH / "Super Mario Theme EPIC VERSION.mp4" | ||
output_path = TMP_PATH / "sounds" / "smb-epic-theme.mp3" | ||
sound.extract_audio(str(videos_path), str(output_path)) | ||
params = { | ||
"input-path": notes_path, | ||
"output-path": mp3_path, | ||
"duration": 2, | ||
} | ||
sound = Sound(params) | ||
sound.notes_to_audio() | ||
|
||
|
||
@pytest.mark.skip | ||
def test_extract_notes_from_mp3(sound): | ||
@unittest.skip("not fully implemented") | ||
def test_extract_notes_from_mp3(): | ||
"""Test the extraction of notes from mp3 file.""" | ||
mp3_path = TMP_PATH / "sounds" / "tok-audio.mp3" | ||
output_notes = TMP_PATH / "notes" / "tok-audio.txt" | ||
notes = sound.extract_notes_from_mp3(str(mp3_path), str(output_notes)) | ||
filename = "pixabay-science" | ||
mp3_path = TEST_DATA_DIR / "audio" / f"{filename}.mp3" | ||
output_notes = TMP_PATH / "notes" / f"{filename}.txt" | ||
params = { | ||
"input-path": mp3_path, | ||
"output-path": output_notes, | ||
} | ||
sound = Sound(params) | ||
notes = sound.extract_notes_from_mp3() | ||
print("Detected notes:", notes) | ||
|
||
|
||
@pytest.mark.skip | ||
def test_generate_melody(sound): | ||
@unittest.skip("not fully implemented") | ||
def test_generate_melody(): | ||
"""Test the melody generation from notes.""" | ||
notes_path = TMP_PATH / "notes" / "tok-audio.txt" | ||
sound.generate_melody(notes_path, total_duration=3.54 * 60) | ||
params = { | ||
"input-path": notes_path, | ||
"output-path": "/tmp/artbox/sound.mp3", | ||
"duration": 3.54 * 60, | ||
} | ||
sound = Sound(params) | ||
sound.generate_melody() | ||
|
||
|
||
@pytest.mark.skip | ||
def test_convert_to_8bit_audio(sound): | ||
@unittest.skip("not fully implemented") | ||
def test_convert_to_8bit_audio(): | ||
"""Test the audio conversion to 8bits style.""" | ||
videos_path = ( | ||
TMP_PATH | ||
/ "videos" | ||
/ "The Legend of Zelda Tears of the Kingdom - Official Trailer 3.mp4" | ||
) | ||
input_path = TEST_DATA_DIR / "audio" / "pixabay-science.mp3" | ||
output_path = TMP_PATH / "sounds" / "tok8bits.mp3" | ||
sound.convert_to_8bit_audio(str(videos_path), str(output_path)) | ||
params = { | ||
"input-path": mp3_path, | ||
"output-path": output_notes, | ||
} | ||
sound = Sound(params) | ||
sound.convert_to_8bit_audio() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,61 @@ | ||
"""Set of tests for the videos module.""" | ||
import os | ||
|
||
from pathlib import Path | ||
|
||
import pytest | ||
|
||
from artbox.videos import Video | ||
from artbox.videos import Video, Youtube | ||
|
||
TMP_PATH = Path("/tmp/artbox") | ||
|
||
TMP_PATH = Path("/tmp/artbox") | ||
TEST_DATA_DIR = Path(__file__).parent / "data" | ||
|
||
@pytest.mark.fixture | ||
def video(): | ||
"""Create a fixture for the Video object.""" | ||
return Video() | ||
os.makedirs(TMP_PATH, exist_ok=True) | ||
|
||
|
||
@pytest.mark.skip | ||
def test_combine_video_and_audio(video): | ||
def test_combine_video_and_audio(): | ||
"""Test the function that combines video and audio.""" | ||
# Example usage | ||
# "The Legend of Zelda Tears of the Kingdom - Official Trailer 3.mp4" | ||
video_path = TMP_PATH / "peachs-no-audio.mp4" | ||
audio_path = TMP_PATH / "smb-epic-theme.mp3" | ||
output_path = TMP_PATH / "peachs-with-music.mp4" | ||
video.combine_video_and_audio( | ||
str(video_path), str(audio_path), str(output_path) | ||
) | ||
video_path = TEST_DATA_DIR / "videos" / "pixabay-fuji.mp4" | ||
audio_path = TEST_DATA_DIR / "audios" / "pixabay-science.mp3" | ||
output_path = TMP_PATH / "video+audio.mp4" | ||
|
||
params = { | ||
"video-path": str(video_path), | ||
"audio-path": str(audio_path), | ||
"output-path": str(output_path), | ||
} | ||
video = Video(params) | ||
video.combine_video_and_audio() | ||
|
||
|
||
@pytest.mark.skip | ||
def test_download_from_youtube(video): | ||
def test_download_from_youtube(): | ||
"""Test the method that downloads videos from youtube.""" | ||
# "https://www.youtube.com/watch?v=uHGShqcAHlQ" | ||
for url in [ | ||
"https://youtube.com/shorts/gmutDetnBLQ", | ||
"https://youtube.com/watch?v=6pjbaE98ftU", | ||
]: | ||
video.download_from_youtube(url) | ||
|
||
|
||
@pytest.mark.skip | ||
def test_remove_audio(video): | ||
for i, url in enumerate( | ||
[ | ||
"https://youtube.com/shorts/gmutDetnBLQ", | ||
"https://youtube.com/watch?v=6pjbaE98ftU", | ||
] | ||
): | ||
params = {"output-path": TMP_PATH, "url": url} | ||
youtube = Youtube(params) | ||
youtube.download() | ||
|
||
|
||
def test_remove_audio(): | ||
"""Test the function that removes audio from a video.""" | ||
input_file = TMP_PATH / ( | ||
"Princess Peachs Training Course in The Super Mario Bros Movie.mp4" | ||
) | ||
output_file = "peachs-no-audio.mp4" | ||
video.remove_audio(input_file, TMP_PATH / output_file) | ||
|
||
params = { | ||
"input-path": TEST_DATA_DIR / "videos" / "pixabay-fuji.mp4", | ||
"output-path": TMP_PATH / "video-with-no-audio.mp4", | ||
} | ||
|
||
video = Video(params) | ||
video.remove_audio() |