mirror of
https://github.com/shirayu/whispering.git
synced 2024-11-25 10:21:00 +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",
|
||||
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):
|
||||
|
@ -139,32 +150,23 @@ def get_wshiper(*, opts):
|
|||
return wsp
|
||||
|
||||
|
||||
def main() -> None:
|
||||
opts = get_opts()
|
||||
|
||||
if opts.show_devices:
|
||||
def show_devices():
|
||||
devices = sd.query_devices()
|
||||
for i, device in enumerate(devices):
|
||||
if device["max_input_channels"] > 0:
|
||||
print(f"{i}: {device['name']}")
|
||||
|
||||
return
|
||||
|
||||
def main() -> None:
|
||||
opts = get_opts()
|
||||
|
||||
basicConfig(
|
||||
level=DEBUG if opts.debug else INFO,
|
||||
format="[%(asctime)s] %(module)s.%(funcName)s:%(lineno)d %(levelname)s -> %(message)s",
|
||||
)
|
||||
|
||||
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
|
||||
if opts.show_devices:
|
||||
return show_devices()
|
||||
|
||||
if opts.host is not None and opts.port is not None:
|
||||
if opts.mode == "client":
|
||||
|
|
Loading…
Reference in a new issue