Merge branch 'model' into UI_2.0
This commit is contained in:
11
model.py
11
model.py
@@ -253,6 +253,9 @@ class Model:
|
||||
return False
|
||||
|
||||
def startMicTranscript(self, fnc):
|
||||
if config.CHOICE_MIC_HOST == "None" or config.CHOICE_MIC_DEVICE == "None":
|
||||
return
|
||||
|
||||
mic_audio_queue = Queue()
|
||||
device = [device for device in getInputDevices()[config.CHOICE_MIC_HOST] if device["name"] == config.CHOICE_MIC_DEVICE][0]
|
||||
record_timeout = config.INPUT_MIC_RECORD_TIMEOUT
|
||||
@@ -294,6 +297,9 @@ class Model:
|
||||
self.mic_audio_recorder = None
|
||||
|
||||
def startCheckMicEnergy(self, fnc):
|
||||
if config.CHOICE_MIC_HOST == "None" or config.CHOICE_MIC_DEVICE == "None":
|
||||
return
|
||||
|
||||
def sendMicEnergy():
|
||||
if mic_energy_queue.empty() is False:
|
||||
energy = mic_energy_queue.get()
|
||||
@@ -320,6 +326,8 @@ class Model:
|
||||
self.mic_energy_recorder = None
|
||||
|
||||
def startSpeakerTranscript(self, fnc):
|
||||
if config.CHOICE_SPEAKER_DEVICE == "None":
|
||||
return
|
||||
spk_audio_queue = Queue()
|
||||
spk_device = [device for device in getOutputDevices() if device["name"] == config.CHOICE_SPEAKER_DEVICE][0]
|
||||
|
||||
@@ -362,6 +370,9 @@ class Model:
|
||||
self.spk_audio_recorder = None
|
||||
|
||||
def startCheckSpeakerEnergy(self, fnc):
|
||||
if config.CHOICE_SPEAKER_DEVICE == "None":
|
||||
return
|
||||
|
||||
def sendSpeakerEnergy():
|
||||
if speaker_energy_queue.empty() is False:
|
||||
energy = speaker_energy_queue.get()
|
||||
|
||||
@@ -12,6 +12,8 @@ def getInputDevices():
|
||||
devices[host["name"]].append(device)
|
||||
else:
|
||||
devices[host["name"]] = [device]
|
||||
if len(devices) == 0:
|
||||
devices = {"None": [{"name": "None"}]}
|
||||
return devices
|
||||
|
||||
def getOutputDevices():
|
||||
@@ -21,6 +23,8 @@ def getOutputDevices():
|
||||
for device in p.get_loopback_device_info_generator():
|
||||
if device["hostApi"] == wasapi_info["index"] and device["isLoopbackDevice"] is True:
|
||||
devices.append(device)
|
||||
if len(devices) == 0:
|
||||
devices = [{'name':"None"}]
|
||||
return devices
|
||||
|
||||
def getDefaultInputDevice():
|
||||
@@ -33,7 +37,8 @@ def getDefaultInputDevice():
|
||||
for device_index in range(0, p. get_host_api_info_by_index(host_index)['deviceCount']):
|
||||
device = p.get_device_info_by_host_api_device_index(host_index, device_index)
|
||||
if device["index"] == defaultInputDevice:
|
||||
return {"host":host, "device": device}
|
||||
return {"host": host, "device": device}
|
||||
return {"host": {"name": "None"}, "device": {"name": "None"}}
|
||||
|
||||
def getDefaultOutputDevice():
|
||||
with PyAudio() as p:
|
||||
@@ -49,4 +54,5 @@ def getDefaultOutputDevice():
|
||||
for loopback in p.get_loopback_device_info_generator():
|
||||
if default_speakers["name"] in loopback["name"]:
|
||||
default_device = loopback
|
||||
return default_device
|
||||
return default_device
|
||||
return {"name":"None"}
|
||||
Reference in New Issue
Block a user