Skip to content

Commit

Permalink
Add audio player
Browse files Browse the repository at this point in the history
  • Loading branch information
chidiwilliams committed Aug 4, 2023
1 parent 6f3cc04 commit 78bcd76
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions buzz/widgets/transcription_viewer_widget.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import platform
from typing import List, Optional

from PyQt6.QtCore import Qt, pyqtSignal
Expand Down Expand Up @@ -87,7 +88,9 @@ def __init__(
self.table_widget.segment_text_changed.connect(self.on_segment_text_changed)
self.table_widget.segment_index_selected.connect(self.on_segment_index_selected)

self.audio_player = AudioPlayer(file_path=transcription_task.file_path)
self.audio_player: Optional[AudioPlayer] = None
if platform.system() != "Linux":
self.audio_player = AudioPlayer(file_path=transcription_task.file_path)

buttons_layout = QHBoxLayout()
buttons_layout.addStretch()
Expand All @@ -108,7 +111,8 @@ def __init__(
layout = QVBoxLayout(self)
layout.setMenuBar(toolbar)
layout.addWidget(self.table_widget)
layout.addWidget(self.audio_player)
if self.audio_player is not None:
layout.addWidget(self.audio_player)
layout.addLayout(buttons_layout)

self.setLayout(layout)
Expand All @@ -124,7 +128,8 @@ def on_segment_text_changed(self, event: tuple):

def on_segment_index_selected(self, index: int):
selected_segment = self.transcription_task.segments[index]
self.audio_player.set_range((selected_segment.start, selected_segment.end))
if self.audio_player is not None:
self.audio_player.set_range((selected_segment.start, selected_segment.end))

def on_menu_triggered(self, action: QAction):
output_format = OutputFormat[action.text()]
Expand Down

0 comments on commit 78bcd76

Please sign in to comment.