aboutsummaryrefslogtreecommitdiffstats
path: root/agl_service_voiceagent/service.py
diff options
context:
space:
mode:
authorMalik Talha <talhamalik727x@gmail.com>2023-11-02 03:11:43 +0500
committerMalik Talha <talhamalik727x@gmail.com>2023-11-02 03:11:43 +0500
commita644c90d7409f48c49fbd5ddca7ecfe35de15953 (patch)
treec513e46850dc6a58ac200ea20a467a23248ac63b /agl_service_voiceagent/service.py
parent42a03d2550f60a8064078f19a743afb944f9ff69 (diff)
Update voice agent service
Modify default configuration, add detailed file based logging functionality, and use placeholders instead of fixed values in default config. Bug-AGL: SPEC-4906 Signed-off-by: Malik Talha <talhamalik727x@gmail.com> Change-Id: Ib75af153555e7cdde38c67414df8326799e22c8d
Diffstat (limited to 'agl_service_voiceagent/service.py')
-rw-r--r--agl_service_voiceagent/service.py70
1 files changed, 45 insertions, 25 deletions
diff --git a/agl_service_voiceagent/service.py b/agl_service_voiceagent/service.py
index 784d8d9..9682b56 100644
--- a/agl_service_voiceagent/service.py
+++ b/agl_service_voiceagent/service.py
@@ -25,15 +25,14 @@ generated_dir = os.path.join(current_dir, "generated")
sys.path.append(generated_dir)
import argparse
-from agl_service_voiceagent.utils.config import set_config_path, load_config, update_config_value, get_config_value
+from agl_service_voiceagent.utils.config import set_config_path, load_config, update_config_value, get_config_value, get_logger
from agl_service_voiceagent.utils.common import add_trailing_slash
from agl_service_voiceagent.server import run_server
from agl_service_voiceagent.client import run_client
-
def print_version():
print("Automotive Grade Linux (AGL)")
- print(f"Voice Agent Service v0.3.0")
+ print(f"Voice Agent Service v0.4.0")
def main():
@@ -59,8 +58,11 @@ def main():
server_parser.add_argument('--audio-store-dir', required=False, help='Directory to store the generated audio files.')
server_parser.add_argument('--log-store-dir', required=False, help='Directory to store the generated log files.')
+ client_parser.add_argument('--server-address', required=True, help='Address of the gRPC server running the Voice Agent Service.')
+ client_parser.add_argument('--server-port', required=True, help='Port of the gRPC server running the Voice Agent Service.')
client_parser.add_argument('--mode', required=True, help='Mode to run the client in. Supported modes: "wake-word", "auto" and "manual".')
- client_parser.add_argument('--nlu', required=True, help='NLU engine to use. Supported NLU egnines: "snips" and "rasa".')
+ client_parser.add_argument('--nlu', help='NLU engine to use. Supported NLU egnines: "snips" and "rasa".')
+ client_parser.add_argument('--recording-time', help='Number of seconds to continue recording the voice command. Required by the \'manual\' mode. Defaults to 10 seconds.')
args = parser.parse_args()
@@ -70,19 +72,24 @@ def main():
elif args.subcommand == 'run-server':
if not args.default and not args.config:
if not args.stt_model_path:
- raise ValueError("The --stt-model-path is missing. Please provide a value. Use --help to see available options.")
+ print("Error: The --stt-model-path is missing. Please provide a value. Use --help to see available options.")
+ exit(1)
if not args.snips_model_path:
- raise ValueError("The --snips-model-path is missing. Please provide a value. Use --help to see available options.")
+ print("Error: The --snips-model-path is missing. Please provide a value. Use --help to see available options.")
+ exit(1)
if not args.rasa_model_path:
- raise ValueError("The --rasa-model-path is missing. Please provide a value. Use --help to see available options.")
+ print("Error: The --rasa-model-path is missing. Please provide a value. Use --help to see available options.")
+ exit(1)
if not args.intents_vss_map_path:
- raise ValueError("The --intents-vss-map-path is missing. Please provide a value. Use --help to see available options.")
+ print("Error: The --intents-vss-map-path is missing. Please provide a value. Use --help to see available options.")
+ exit(1)
if not args.vss_signals_spec_path:
- raise ValueError("The --vss-signals-spec is missing. Please provide a value. Use --help to see available options.")
+ print("Error: The --vss-signals-spec-path is missing. Please provide a value. Use --help to see available options.")
+ exit(1)
# Contruct the default config file path
config_path = os.path.join(current_dir, "config.ini")
@@ -90,6 +97,9 @@ def main():
# Load the config values from the config file
set_config_path(config_path)
load_config()
+
+ logger = get_logger()
+ logger.info("Starting Voice Agent Service in server mode using CLI provided params...")
# Get the values provided by the user
stt_path = args.stt_model_path
@@ -135,6 +145,9 @@ def main():
print(f"New config file path provided: {cli_config_path}. Overriding the default config file path.")
set_config_path(cli_config_path)
load_config()
+
+ logger = get_logger()
+ logger.info(f"Starting Voice Agent Service in server mode using provided config file at path '{cli_config_path}' ...")
elif args.default:
# Contruct the default config file path
@@ -144,33 +157,40 @@ def main():
set_config_path(config_path)
load_config()
+ logger = get_logger()
+ logger.info(f"Starting Voice Agent Service in server mode using the default config file...")
+
# create the base audio dir if not exists
if not os.path.exists(get_config_value('BASE_AUDIO_DIR')):
os.makedirs(get_config_value('BASE_AUDIO_DIR'))
-
- # create the base log dir if not exists
- if not os.path.exists(get_config_value('BASE_LOG_DIR')):
- os.makedirs(get_config_value('BASE_LOG_DIR'))
run_server()
elif args.subcommand == 'run-client':
- # Contruct the default config file path
- config_path = os.path.join(current_dir, "config.ini")
-
- # Load the config values from the config file
- set_config_path(config_path)
- load_config()
-
+ server_address = args.server_address
+ server_port = args.server_port
+ nlu_engine = ""
mode = args.mode
+ recording_time = 5
+
if mode not in ['wake-word', 'auto', 'manual']:
- raise ValueError("Invalid mode. Supported modes: 'wake-word', 'auto' and 'manual'. Use --help to see available options.")
+ print("Error: Invalid value for --mode. Supported modes: 'wake-word', 'auto' and 'manual'. Use --help to see available options.")
+ exit(1)
- model = args.nlu
- if model not in ['snips', 'rasa']:
- raise ValueError("Invalid NLU engine. Supported NLU engines: 'snips' and 'rasa'. Use --help to see available options.")
+ if mode in ["auto", "manual"]:
+ if not args.nlu:
+ print("Error: The --nlu flag is missing. Please provide a value for intent engine. Supported NLU engines: 'snips' and 'rasa'. Use --help to see available options.")
+ exit(1)
+
+ nlu_engine = args.nlu
+ if nlu_engine not in ['snips', 'rasa']:
+ print("Error: Invalid value for --nlu. Supported NLU engines: 'snips' and 'rasa'. Use --help to see available options.")
+ exit(1)
+
+ if mode == "manual" and args.recording_time:
+ recording_time = int(args.recording_time)
- run_client(mode, model)
+ run_client(server_address, server_port, mode, nlu_engine, recording_time)
else:
print_version()