Skip to content

Commit

Permalink
Add warning for mp3 format
Browse files Browse the repository at this point in the history
  • Loading branch information
flutydeer committed Jul 29, 2024
1 parent 45f5820 commit e97dcd0
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 56 deletions.
10 changes: 5 additions & 5 deletions file_version_info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ VSVersionInfo(
ffi=FixedFileInfo(
# filevers and prodvers should be always a tuple with four items: (1, 2, 3, 4)
# Set not needed items to zero 0.
filevers=(1, 2, 1, 0),
prodvers=(1, 2, 1, 0),
filevers=(1, 3, 0, 0),
prodvers=(1, 3, 0, 0),
# Contains a bitmask that specifies the valid bits 'flags'r
mask=0x0,
# Contains a bitmask that specifies the Boolean attributes of the file.
Expand All @@ -31,12 +31,12 @@ VSVersionInfo(
'000904b0',
[StringStruct('CompanyName', 'OpenVPI Team'),
StringStruct('FileDescription', 'Audio Slicer'),
StringStruct('FileVersion', '1.2.1.0'),
StringStruct('FileVersion', '1.3.0.0'),
StringStruct('InternalName', 'slicer-gui.exe'),
StringStruct('LegalCopyright', 'Copyright 2020-2023 OpenVPI Team'),
StringStruct('LegalCopyright', 'Copyright 2020-2024 OpenVPI Team'),
StringStruct('OriginalFilename', 'slicer-gui.exe'),
StringStruct('ProductName', 'Audio Slicer'),
StringStruct('ProductVersion', '1.2.1.0')])
StringStruct('ProductVersion', '1.3.0.0')])
]),
VarFileInfo([VarStruct('Translation', [9, 1200])])
]
Expand Down
58 changes: 29 additions & 29 deletions gui/Ui_MainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
################################################################################
## Form generated from reading UI file 'ui_mainwindow.ui'
##
## Created by: Qt User Interface Compiler version 6.5.0
## Created by: Qt User Interface Compiler version 6.7.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
Expand Down Expand Up @@ -38,15 +38,15 @@ def setupUi(self, MainWindow):
self.pushButtonAddFiles = QPushButton(self.centralwidget)
self.pushButtonAddFiles.setObjectName(u"pushButtonAddFiles")
self.pushButtonAddFiles.setEnabled(True)
sizePolicy = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
sizePolicy = QSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Fixed)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButtonAddFiles.sizePolicy().hasHeightForWidth())
self.pushButtonAddFiles.setSizePolicy(sizePolicy)

self.horizontalLayout_2.addWidget(self.pushButtonAddFiles)

self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.horizontalSpacer = QSpacerItem(40, 20, QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Minimum)

self.horizontalLayout_2.addItem(self.horizontalSpacer)

Expand All @@ -57,7 +57,7 @@ def setupUi(self, MainWindow):
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.groupBox = QGroupBox(self.centralwidget)
self.groupBox.setObjectName(u"groupBox")
sizePolicy1 = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Minimum)
sizePolicy1 = QSizePolicy(QSizePolicy.Policy.Preferred, QSizePolicy.Policy.Minimum)
sizePolicy1.setHorizontalStretch(0)
sizePolicy1.setVerticalStretch(0)
sizePolicy1.setHeightForWidth(self.groupBox.sizePolicy().hasHeightForWidth())
Expand All @@ -66,7 +66,7 @@ def setupUi(self, MainWindow):
self.verticalLayout_2.setObjectName(u"verticalLayout_2")
self.listWidgetTaskList = QListWidget(self.groupBox)
self.listWidgetTaskList.setObjectName(u"listWidgetTaskList")
self.listWidgetTaskList.setFrameShadow(QFrame.Plain)
self.listWidgetTaskList.setFrameShadow(QFrame.Shadow.Plain)

self.verticalLayout_2.addWidget(self.listWidgetTaskList)

Expand All @@ -93,7 +93,7 @@ def setupUi(self, MainWindow):

self.lineEditThreshold = QLineEdit(self.groupBox_2)
self.lineEditThreshold.setObjectName(u"lineEditThreshold")
self.lineEditThreshold.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.lineEditThreshold.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)

self.formLayout.setWidget(0, QFormLayout.FieldRole, self.lineEditThreshold)

Expand All @@ -104,7 +104,7 @@ def setupUi(self, MainWindow):

self.lineEditMinLen = QLineEdit(self.groupBox_2)
self.lineEditMinLen.setObjectName(u"lineEditMinLen")
self.lineEditMinLen.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.lineEditMinLen.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)

self.formLayout.setWidget(1, QFormLayout.FieldRole, self.lineEditMinLen)

Expand All @@ -115,7 +115,7 @@ def setupUi(self, MainWindow):

self.lineEditMinInterval = QLineEdit(self.groupBox_2)
self.lineEditMinInterval.setObjectName(u"lineEditMinInterval")
self.lineEditMinInterval.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.lineEditMinInterval.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)

self.formLayout.setWidget(2, QFormLayout.FieldRole, self.lineEditMinInterval)

Expand All @@ -126,7 +126,7 @@ def setupUi(self, MainWindow):

self.lineEditHopSize = QLineEdit(self.groupBox_2)
self.lineEditHopSize.setObjectName(u"lineEditHopSize")
self.lineEditHopSize.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.lineEditHopSize.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)

self.formLayout.setWidget(3, QFormLayout.FieldRole, self.lineEditHopSize)

Expand All @@ -137,7 +137,7 @@ def setupUi(self, MainWindow):

self.lineEditMaxSilence = QLineEdit(self.groupBox_2)
self.lineEditMaxSilence.setObjectName(u"lineEditMaxSilence")
self.lineEditMaxSilence.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter)
self.lineEditMaxSilence.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignTrailing|Qt.AlignmentFlag.AlignVCenter)

self.formLayout.setWidget(4, QFormLayout.FieldRole, self.lineEditMaxSilence)

Expand All @@ -153,7 +153,7 @@ def setupUi(self, MainWindow):
self.horizontalLayout_4.setObjectName(u"horizontalLayout_4")
self.lineEditOutputDir = QLineEdit(self.groupBox_2)
self.lineEditOutputDir.setObjectName(u"lineEditOutputDir")
self.lineEditOutputDir.setAlignment(Qt.AlignLeading|Qt.AlignLeft|Qt.AlignVCenter)
self.lineEditOutputDir.setAlignment(Qt.AlignmentFlag.AlignLeading|Qt.AlignmentFlag.AlignLeft|Qt.AlignmentFlag.AlignVCenter)

self.horizontalLayout_4.addWidget(self.lineEditOutputDir)

Expand All @@ -172,35 +172,35 @@ def setupUi(self, MainWindow):

self.horizontalLayout_5.addWidget(self.label)

self.radioButton = QRadioButton(self.groupBox_2)
self.radioButtonWav = QRadioButton(self.groupBox_2)
self.buttonGroup = QButtonGroup(MainWindow)
self.buttonGroup.setObjectName(u"buttonGroup")
self.buttonGroup.addButton(self.radioButton)
self.radioButton.setObjectName(u"radioButton")
self.radioButton.setText(u"wav")
self.radioButton.setChecked(True)
self.buttonGroup.addButton(self.radioButtonWav)
self.radioButtonWav.setObjectName(u"radioButtonWav")
self.radioButtonWav.setText(u"wav")
self.radioButtonWav.setChecked(True)

self.horizontalLayout_5.addWidget(self.radioButton, 0, Qt.AlignHCenter)
self.horizontalLayout_5.addWidget(self.radioButtonWav, 0, Qt.AlignmentFlag.AlignHCenter)

self.radioButton_1 = QRadioButton(self.groupBox_2)
self.buttonGroup.addButton(self.radioButton_1)
self.radioButton_1.setObjectName(u"radioButton_1")
self.radioButton_1.setText(u"flac")
self.radioButtonFlac = QRadioButton(self.groupBox_2)
self.buttonGroup.addButton(self.radioButtonFlac)
self.radioButtonFlac.setObjectName(u"radioButtonFlac")
self.radioButtonFlac.setText(u"flac")

self.horizontalLayout_5.addWidget(self.radioButton_1, 0, Qt.AlignHCenter)
self.horizontalLayout_5.addWidget(self.radioButtonFlac, 0, Qt.AlignmentFlag.AlignHCenter)

self.radioButton_2 = QRadioButton(self.groupBox_2)
self.buttonGroup.addButton(self.radioButton_2)
self.radioButton_2.setObjectName(u"radioButton_2")
self.radioButton_2.setEnabled(True)
self.radioButton_2.setText(u"mp3")
self.radioButtonMp3 = QRadioButton(self.groupBox_2)
self.buttonGroup.addButton(self.radioButtonMp3)
self.radioButtonMp3.setObjectName(u"radioButtonMp3")
self.radioButtonMp3.setEnabled(True)
self.radioButtonMp3.setText(u"mp3")

self.horizontalLayout_5.addWidget(self.radioButton_2, 0, Qt.AlignHCenter)
self.horizontalLayout_5.addWidget(self.radioButtonMp3, 0, Qt.AlignmentFlag.AlignHCenter)


self.verticalLayout_3.addLayout(self.horizontalLayout_5)

self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.verticalSpacer = QSpacerItem(20, 40, QSizePolicy.Policy.Minimum, QSizePolicy.Policy.Expanding)

self.verticalLayout_3.addItem(self.verticalSpacer)

Expand Down
23 changes: 18 additions & 5 deletions gui/mainwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ def __init__(self):
self.setAcceptDrops(True)

# Get available formats/extensions supported
self.availableFormats = [str(formatExt).lower() for formatExt in soundfile.available_formats().keys()]
self.availableFormats = [str(formatExt).lower(
) for formatExt in soundfile.available_formats().keys()]
# libsndfile supports Opus in Ogg container
# .opus is a valid extension and recommended for Ogg Opus (see RFC 7845, Section 9)
# append opus for convenience as tools like youtube-dl(p) extract to .opus by default
self.availableFormats.append("opus")

self.formatAllFilter = " ".join([f"*.{formatExt}" for formatExt in self.availableFormats])
self.formatIndividualFilter = ";;".join([f"{formatExt} (*.{formatExt})" for formatExt in sorted(self.availableFormats)])
self.formatAllFilter = " ".join(
[f"*.{formatExt}" for formatExt in self.availableFormats])
self.formatIndividualFilter = ";;".join(
[f"{formatExt} (*.{formatExt})" for formatExt in sorted(self.availableFormats)])

def _q_browse_output_dir(self):
path = QFileDialog.getExistingDirectory(
Expand Down Expand Up @@ -91,7 +94,7 @@ def _q_clear_audio_list(self):

def _q_about(self):
QMessageBox.information(
self, "About", "Audio Slicer v1.2.1\nCopyright 2020-2023 OpenVPI Team")
self, "About", "Audio Slicer v1.3.0\nCopyright 2020-2024 OpenVPI Team")

def _q_start(self):
if self.processing:
Expand All @@ -102,6 +105,16 @@ def _q_start(self):
if item_count == 0:
return

output_format = self.ui.buttonGroup.checkedButton().text()
if output_format == "mp3":
ret = QMessageBox.warning(self, "Warning",
"MP3 is not recommended for saving vocals as it is lossy. "
"If you want to save disk space, consider using FLAC instead. "
"Do you want to continue?",
QMessageBox.Ok | QMessageBox.Cancel, QMessageBox.Cancel)
if ret == QMessageBox.Cancel:
return

class WorkThread(QThread):
oneFinished = Signal()

Expand Down Expand Up @@ -140,7 +153,7 @@ def run(self):
ext = self.win.ui.buttonGroup.checkedButton().text()
for i, chunk in enumerate(chunks):
path = os.path.join(out_dir, f'%s_%d.{ext}' % (os.path.basename(filename)
.rsplit('.', maxsplit=1)[0], i))
.rsplit('.', maxsplit=1)[0], i))
if not is_mono:
chunk = chunk.T
soundfile.write(path, chunk, sr)
Expand Down
30 changes: 15 additions & 15 deletions gui/ui_mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down Expand Up @@ -70,7 +70,7 @@
<item>
<widget class="QListWidget" name="listWidgetTaskList">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<enum>QFrame::Shadow::Plain</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -111,7 +111,7 @@
<string>-40</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
Expand All @@ -128,7 +128,7 @@
<string>5000</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
Expand All @@ -145,7 +145,7 @@
<string>300</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
Expand All @@ -162,7 +162,7 @@
<string>10</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
Expand All @@ -179,7 +179,7 @@
<string>1000</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
Expand All @@ -200,7 +200,7 @@
<string/>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
Expand All @@ -222,8 +222,8 @@
</property>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="radioButton">
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QRadioButton" name="radioButtonWav">
<property name="text">
<string notr="true">wav</string>
</property>
Expand All @@ -235,8 +235,8 @@
</attribute>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="radioButton_1">
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QRadioButton" name="radioButtonFlac">
<property name="text">
<string notr="true">flac</string>
</property>
Expand All @@ -245,8 +245,8 @@
</attribute>
</widget>
</item>
<item alignment="Qt::AlignHCenter">
<widget class="QRadioButton" name="radioButton_2">
<item alignment="Qt::AlignmentFlag::AlignHCenter">
<widget class="QRadioButton" name="radioButtonMp3">
<property name="enabled">
<bool>true</bool>
</property>
Expand All @@ -263,7 +263,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
Binary file modified screenshots/screenshot_dark.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified screenshots/screenshot_light.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions slicer-gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
style = QStyleFactory.create("fusion")
app.setStyle(style)

font = QFont('Microsoft YaHei UI')
font.setPixelSize(12)
font = QFont()
# font.setPixelSize(12)
font.setHintingPreference(QFont.PreferNoHinting)
app.setFont(font)

window = gui.mainwindow.MainWindow()
Expand Down

0 comments on commit e97dcd0

Please sign in to comment.