mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-29 04:21:07 +00:00
Refactoring
This commit is contained in:
parent
ff681be9b2
commit
62698bcdde
1 changed files with 21 additions and 19 deletions
|
@ -120,8 +120,19 @@ def get_opts() -> argparse.Namespace:
|
||||||
"--show-devices",
|
"--show-devices",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
)
|
)
|
||||||
|
opts = parser.parse_args()
|
||||||
|
|
||||||
return parser.parse_args()
|
if opts.beam_size <= 0:
|
||||||
|
opts.beam_size = None
|
||||||
|
if len(opts.temperature) == 0:
|
||||||
|
opts.temperature = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
|
||||||
|
opts.temperature = sorted(set(opts.temperature))
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts.mic = int(opts.mic)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return opts
|
||||||
|
|
||||||
|
|
||||||
def get_wshiper(*, opts):
|
def get_wshiper(*, opts):
|
||||||
|
@ -139,32 +150,23 @@ def get_wshiper(*, opts):
|
||||||
return wsp
|
return wsp
|
||||||
|
|
||||||
|
|
||||||
|
def show_devices():
|
||||||
|
devices = sd.query_devices()
|
||||||
|
for i, device in enumerate(devices):
|
||||||
|
if device["max_input_channels"] > 0:
|
||||||
|
print(f"{i}: {device['name']}")
|
||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
opts = get_opts()
|
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(
|
basicConfig(
|
||||||
level=DEBUG if opts.debug else INFO,
|
level=DEBUG if opts.debug else INFO,
|
||||||
format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s",
|
format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s",
|
||||||
)
|
)
|
||||||
|
|
||||||
if opts.beam_size <= 0:
|
if opts.show_devices:
|
||||||
opts.beam_size = None
|
return show_devices()
|
||||||
if len(opts.temperature) == 0:
|
|
||||||
opts.temperature = [0.0, 0.2, 0.4, 0.6, 0.8, 1.0]
|
|
||||||
opts.temperature = sorted(set(opts.temperature))
|
|
||||||
|
|
||||||
try:
|
|
||||||
opts.mic = int(opts.mic)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if opts.host is not None and opts.port is not None:
|
if opts.host is not None and opts.port is not None:
|
||||||
if opts.mode == "client":
|
if opts.mode == "client":
|
||||||
|
|
Loading…
Reference in a new issue