Merge pull request #10 from All-Ki/show-available-devices

add --show-devices option to list available microphones
This commit is contained in:
Yuta Hayashibe 2022-09-27 12:17:51 +09:00 committed by GitHub
commit 7cdecf8deb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -116,6 +116,10 @@ def get_opts() -> argparse.Namespace:
"--mode",
choices=["client"],
)
parser.add_argument(
"--show-devices",
action="store_true",
)
return parser.parse_args()
@ -137,6 +141,15 @@ def get_wshiper(*, opts):
def main() -> None:
opts = get_opts()
if(opts.show_devices) :
devices = sd.query_devices()
for i, device in enumerate(devices):
if(device["max_input_channels"] > 0) :
print(f"{i}: {device['name']}")
return
basicConfig(
level=DEBUG if opts.debug else INFO,
format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s",