-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSong.py
More file actions
31 lines (27 loc) · 984 Bytes
/
Song.py
File metadata and controls
31 lines (27 loc) · 984 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pygame import mixer
class Song:
"""
title: Song title.
artist: Song artist.
duration: Length of song in seconds.
file: Music file location.
timestamps: List of timestamps and lyrics formatted as [[timestamp, lyric, wpm], ...]
lyrics: The lyrics of the song, padded with empty strings at start and end.
wpm_list: The WPM required to type each lyric.
"""
def __init__(self, title: str, artist: str, duration: int, file: str, timestamps: list[list], lyrics: list[str], max_wpm: int, average_wpm: int):
self.title = title
self.artist = artist
self.duration = duration
self.file = file
self.timestamps = timestamps
self.lyrics = lyrics
self.max_wpm = max_wpm
self.average_wpm = average_wpm
def play(self):
mixer.init()
mixer.music.load(self.file)
mixer.music.play()
mixer.music.set_volume(0.2)
def stop(self):
mixer.music.stop()