Skip to content

Commit

Permalink
完成编辑界面
Browse files Browse the repository at this point in the history
  • Loading branch information
kslz committed Jun 18, 2023
1 parent a67b195 commit ca9bb5f
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 10 deletions.
28 changes: 25 additions & 3 deletions ui/mydialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
@Author : 李子
@Url : https://github.com/kslz
"""
from PySide6.QtCore import QRect
from PySide6.QtCore import QRect, Signal
from PySide6.QtWidgets import QDialog, QMessageBox, QFileDialog

from ui.mywidget import AudioButton
from ui.mywidget import AudioButton, AudioNowButton
from ui.pyuic.ui_add_authorizationinfo import Ui_AddAuthenticationDialog
from ui.pyuic.ui_biaobei_pingce import Ui_BiaobeiPingceDialog
from ui.pyuic.ui_del_info_wav import Ui_del_info_wav_Dialog
Expand All @@ -22,6 +22,8 @@


class EditInfo(QDialog):
windowClosed = Signal()

def __init__(self, parent, info_id):
super().__init__(parent)
# 使用ui文件导入定义界面类
Expand All @@ -30,6 +32,8 @@ def __init__(self, parent, info_id):
self.ui.setupUi(self)
self.info_id = info_id
self.add_info()
self.ui.pushButton_3.clicked.connect(self.update_info)
self.ui.pushButton_2.clicked.connect(self.close)

def add_info(self):
info = Info.get_by_id(self.info_id)
Expand All @@ -47,9 +51,27 @@ def add_info(self):
self.ui.label_info_speaker.setText(speaker)

# self.btn_shiting = PlayNowSoundBTN('试听', self)
self.btn_shiting = AudioButton(wav_path, int(start_time), int(end_time), self)
self.btn_shiting = AudioNowButton(wav_path, int(start_time), int(end_time), self)
self.btn_shiting.clicked.connect(self.shiting)
# btn_sc.clicked.connect(lambda: self.del_dataset(dataset_id, dataset_name))
self.btn_shiting.setGeometry(QRect(290, 20, 91, 24))

def shiting(self):
start_time = self.ui.lineEdit_info_starttime.text()
end_time = self.ui.lineEdit_info_endtime.text()
self.btn_shiting.on_button_clicked_new(start_time, end_time)

def update_info(self):
text = self.ui.lineEdit_info_text.text()
start_time = self.ui.lineEdit_info_starttime.text()
end_time = self.ui.lineEdit_info_endtime.text()
update_info(text, start_time, end_time, self.info_id)
self.close()

def closeEvent(self, event):
self.windowClosed.emit()
super().closeEvent(event)


class BiaobeiPingce(QDialog):
def __init__(self, parent, dataset_id):
Expand Down
6 changes: 1 addition & 5 deletions ui/mygui.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,9 @@ def add_from_file_long_wav(self):
add_long_wav_window.exec_()

def edit_info(self, info_id):
# print("触发编辑")
# print(info_id)
edit_info_window = EditInfo(self,info_id)
edit_info_window.windowClosed.connect(self.refresh_table)
edit_info_window.exec_()

# add_long_wav_window = SelectLongWavFile(self, self.dataset_id)
# add_long_wav_window.exec_()
pass


Expand Down
14 changes: 12 additions & 2 deletions ui/mywidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def on_button_clicked(self):
self.setText("试听")
else:
# 如果音频没有在播放,开始播放
self.audio_thread = AudioThread(self.wav_path,self.start_time,self.end_time)
self.audio_thread = AudioThread(self.wav_path, self.start_time, self.end_time)
self.audio_thread.finished.connect(self.on_audio_finished)
self.audio_thread.start()
self.setText("停止")
Expand Down Expand Up @@ -165,11 +165,21 @@ def run(self):
self.process = subprocess.Popen(['ffplay', "-nodisp", "-autoexit", '-'], stdin=subprocess.PIPE)
self.process.communicate(output[0])


self.is_playing = False
self.finished.emit() # 发送播放完成的信号

def stop(self):
if self.process and self.process.poll() is None: # 检查子进程是否在运行
self.process.terminate() # 终止子进程


class AudioNowButton(AudioButton):
def __init__(self, wav_path, start_time, end_time, parent=None):
super().__init__(wav_path, start_time, end_time, parent)
self.clicked.disconnect(super().on_button_clicked)

def on_button_clicked_new(self, start_time, end_time):
self.start_time = int(start_time)
self.end_time = int(end_time)

self.on_button_clicked()
8 changes: 8 additions & 0 deletions utils/peewee_orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ def get_speakers(dataset_id):
result_list.append(row_result)
return result_list


def get_file_raw_path_by_dataset_id(dataset_id):
query = Info.select(Info.info_raw_file_path).distinct().where(Info.dataset_id == dataset_id)
return list(query)
Expand Down Expand Up @@ -271,11 +272,18 @@ def get_output_info(dataset_id, spk_info):
return result


def update_info(text, start_time, end_time, info_id):
updated_row = Info.update(info_text=text, info_start_time=start_time, info_end_time=end_time) \
.where(Info.info_id == info_id).execute()
print(updated_row)


def insert_info_many(data_list, batch_size=1000):
for i in range(0, len(data_list), batch_size):
with db.atomic():
Info.insert_many(data_list[i:i + batch_size]).execute()


def del_info_by_raw_file_path(file_path):
query = Info.delete().where(Info.info_raw_file_path == file_path)
query.execute()
Expand Down

0 comments on commit ca9bb5f

Please sign in to comment.