-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.py
More file actions
64 lines (51 loc) · 2.01 KB
/
cli.py
File metadata and controls
64 lines (51 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
"""convers entrypoint: hybrid Python + Rust voice agent."""
from __future__ import annotations
import logging
import os
import sys
from pathlib import Path
from typing import List, Optional
# Default-enable the STT input dump alongside this entrypoint. Each
# utterance handed to STT lands as `stt_dumps/utt_NNNN.{wav,txt}` under
# the directory cli.py is run from. Override via VOICE_AGENT_STT_DUMP_DIR
# or set it empty to disable. Path is resolved against CWD, so run
# cli.py from the repo root for consistent results.
os.environ.setdefault("VOICE_AGENT_STT_DUMP_DIR", "./stt_dumps")
from convers.agent import HybridVoiceAgent
from convers.config import build_cli_overrides, parse_args, resolve_model_config
LOG_LEVEL = os.getenv("VOICE_AGENT_LOG_LEVEL", "INFO").upper()
LOG_FORMAT = os.getenv(
"VOICE_AGENT_LOG_FORMAT",
"%(asctime)s | %(levelname)s | %(message)s",
)
logging.basicConfig(
level=getattr(logging, LOG_LEVEL, logging.INFO),
format=LOG_FORMAT,
handlers=[logging.StreamHandler()],
force=True,
)
logger = logging.getLogger(__name__)
def main(argv: Optional[List[str]] = None):
args = parse_args(argv)
cli_overrides = build_cli_overrides(args)
default_config_path = Path(__file__).with_name("config").joinpath("models.json")
try:
model_config, config_path = resolve_model_config(args.config, cli_overrides, default_config_path)
except Exception as exc:
logger.error("❌ Failed to load model configuration: %s", exc)
sys.exit(1)
if config_path:
logger.info("🧾 Using model configuration from %s", config_path)
else:
logger.info("🧾 Using built-in model configuration")
if logger.isEnabledFor(logging.DEBUG):
logger.debug("Resolved model config: %s", model_config.as_dict())
try:
agent = HybridVoiceAgent(model_config=model_config)
agent.run()
except Exception as exc:
logger.error("❌ Failed to start: %s", exc)
sys.exit(1)
if __name__ == "__main__":
main()