def __init__(self, rate, fmt, channels): self.lock = threading.Lock() self.ctx = cubeb.Context() params = cubeb.StreamParams(rate=rate, format=fmt, channels=channels) self.buffer = [] self.stream = self.ctx.new_output_stream("player", None, params, latency=-1, data_cb=self._source) self.stream.start()
from talon import Module, actions, app, imgui, scripting from talon.lib import cubeb from talon.microphone import manager ctx = cubeb.Context() mod = Module() def devices_changed(device_type): update_microphone_list() microphone_device_list = [] def update_microphone_list(): global microphone_device_list microphone_device_list = [] for device in ctx.inputs(): if str(device.state) == "DeviceState.ENABLED": microphone_device_list.append(device) @imgui.open(software=False) def gui(gui: imgui.GUI): gui.text("Select a Microphone") gui.line() for index, item in enumerate(microphone_device_list, 1): if gui.button("{}. {}".format(index, item.name)): actions.user.microphone_select(index)