Fix realtime gui under linux (#609)

* Fix init problem about devices index outbound

* Fix file browse file type

* Fix sd stream channels problem, fix it to 2

---------

Co-authored-by: 源文雨 <41315874+fumiama@users.noreply.github.com>
This commit is contained in:
Yurzi 2023-06-28 13:53:52 +08:00 committed by GitHub
parent 7fc6642c04
commit 5ca7736b2d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 9 deletions

19
gui.py
View File

@ -254,17 +254,17 @@ class GUI:
self.launcher()
def load(self):
input_devices, output_devices, _, _ = self.get_devices()
input_devices, output_devices, input_devices_indices, output_devices_indices = self.get_devices()
try:
with open("values1.json", "r") as j:
data = json.load(j)
except:
with open("values1.json", "w") as j:
data = {
"pth_path": " ",
"index_path": " ",
"sg_input_device": input_devices[sd.default.device[0]],
"sg_output_device": output_devices[sd.default.device[1]],
"pth_path": "",
"index_path": "",
"sg_input_device": input_devices[input_devices_indices.index(sd.default.device[0])],
"sg_output_device": output_devices[output_devices_indices.index(sd.default.device[1])],
"threhold": "-45",
"pitch": "0",
"index_rate": "0",
@ -292,7 +292,7 @@ class GUI:
sg.FileBrowse(
i18n("Hubert模型"),
initial_folder=os.path.join(os.getcwd()),
file_types=((". pt"),),
file_types=(("pt files", "*.pt"),),
),
],
[
@ -303,7 +303,7 @@ class GUI:
sg.FileBrowse(
i18n("选择.pth文件"),
initial_folder=os.path.join(os.getcwd(), "weights"),
file_types=((". pth"),),
file_types=(("weight files", "*.pth"),),
),
],
[
@ -314,7 +314,7 @@ class GUI:
sg.FileBrowse(
i18n("选择.index文件"),
initial_folder=os.path.join(os.getcwd(), "logs"),
file_types=((". index"),),
file_types=(("index files", "*.index"),),
),
],
[
@ -326,7 +326,7 @@ class GUI:
sg.FileBrowse(
i18n("选择.npy文件"),
initial_folder=os.path.join(os.getcwd(), "logs"),
file_types=((". npy"),),
file_types=(("feature files", "*.npy"),),
),
],
],
@ -550,6 +550,7 @@ class GUI:
接受音频输入
"""
with sd.Stream(
channels=2,
callback=self.audio_callback,
blocksize=self.block_frame,
samplerate=self.config.samplerate,