Skip to content

Commit

Permalink
change to detect-topics and topics
Browse files Browse the repository at this point in the history
  • Loading branch information
aaron_ng committed Aug 17, 2023
1 parent 5e7bbe0 commit 9a8cb41
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
11 changes: 4 additions & 7 deletions speechmatics/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,12 @@ def get_transcription_config(
config["sentiment_analysis_config"] = SentimentAnalysisConfig()

topic_detection_config = config.get("topic_detection_config", {})
args_topic_detection = args.get("topic_detection")
args_topic_detection = args.get("detect_topics")
if args_topic_detection or topic_detection_config:
topic_detection_config = TopicDetectionConfig()
topics = (
args_topic_detection.split(",")
if args_topic_detection
else topic_detection_config.get("target_languages")
)
topic_detection_config.topics = topics
topics = args.get("topics", topic_detection_config.get("topics"))
if topics:
topic_detection_config.topics = topics
config["topic_detection_config"] = topic_detection_config

if args["mode"] == "rt":
Expand Down
6 changes: 3 additions & 3 deletions speechmatics/cli_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,14 +286,14 @@ def get_arg_parser():
# Parent parser for batch topic-detection argument
batch_topic_detection_parser = argparse.ArgumentParser(add_help=False)
batch_topic_detection_parser.add_argument(
"--topic-detection",
dest="topic_detection",
"--detect-topics",
dest="detect_topics",
action="store_true",
default=False,
help="Whether to detect topics in transcript",
)
batch_topic_detection_parser.add_argument(
"--topic-detection-topics",
"--topics",
dest="topics",
default=None,
type=str,
Expand Down
10 changes: 5 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,20 +301,20 @@
},
),
(
["batch", "transcribe", "--topic-detection"],
["batch", "transcribe", "--detect-topics"],
{
"topic_detection": True,
"detect_topics": True,
},
),
(
[
"batch",
"transcribe",
"--topic-detection",
"--topic-detection-topics=topic1,topic2,topic3",
"--detect-topics",
"--topics=topic1,topic2,topic3",
],
{
"topic_detection": True,
"detect_topics": True,
"topics": "topic1,topic2,topic3",
},
),
Expand Down

0 comments on commit 9a8cb41

Please sign in to comment.