feat: Hinzufügen einer Zeitanzeige zur Benutzeroberfläche
Co-authored-by: aider (ollama/qwen2.5-coder:14b) <aider@aider.chat>
This commit is contained in:
1 parent
e0e9cf8d73
commit
2665d8eee1
1 file changed
+18
-4
@@ -6,10 +6,6 @@ import soundfile as sf
|
||||
import numpy as np
|
||||
import time
|
||||
from PyQt6.QtGui import QAction, QPen
|
||||
from PyQt6.QtCore import Qt, QTimer
|
||||
import sounddevice as sd
|
||||
import soundfile as sf
|
||||
import numpy as np
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self):
|
||||
@@ -211,6 +207,24 @@ class MainWindow(QMainWindow):
|
||||
outdata[chunksize:].fill(0)
|
||||
self.playback_pos += chunksize
|
||||
|
||||
def update_time_label(self):
|
||||
if self.audio_data is None:
|
||||
self.time_label.setText("00:00 / 00:00")
|
||||
return
|
||||
|
||||
current_time = self.playback_pos / self.sample_rate
|
||||
total_time = len(self.audio_data) / self.sample_rate
|
||||
|
||||
current_time_str = self.format_time(current_time)
|
||||
total_time_str = self.format_time(total_time)
|
||||
|
||||
self.time_label.setText(f"{current_time_str} / {total_time_str}")
|
||||
|
||||
def format_time(self, time_seconds):
|
||||
minutes = int(time_seconds // 60)
|
||||
seconds = int(time_seconds % 60)
|
||||
return f"{minutes:02}:{seconds:02}"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app = QApplication(sys.argv)
|
||||
window = MainWindow()
|
||||
|
||||
Reference in new issue
Block a user