Skip to content

Commit

Permalink
extend schema for spotted keywords
Browse files Browse the repository at this point in the history
  • Loading branch information
markheger committed Apr 1, 2020
1 parent 4a6444a commit ac3b0ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion package/streamsx/sttgateway/_sttgateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,6 @@ def max_utterance_alternatives(self):
def max_utterance_alternatives(self, value):
self._max_utterance_alternatives = value


@property
def non_final_utterances_needed(self):
"""
Expand Down Expand Up @@ -276,6 +275,9 @@ def populate(self, topology, stream, schema, name, **options):
if schema is GatewaySchema.STTResult:
is_stt_result_schema = True

if self.keywords_to_be_spotted is not None and is_stt_result_schema:
schema = schema.extend(GatewaySchema.STTResultKeywordExtension)

if isinstance(self.credentials, dict):
url, access_token, api_key, iam_token_url = _read_credentials(self.credentials)
app_config_name = None
Expand All @@ -297,6 +299,8 @@ def populate(self, topology, stream, schema, name, **options):
if self.keywords_spotting_threshold is not None:
_op.params['keywordsSpottingThreshold'] = streamsx.spl.types.float64(self.keywords_spotting_threshold)
if self.keywords_to_be_spotted is not None:
if is_stt_result_schema:
_op.keywordsSpottingResults = _op.output(_op.outputs[0], _op.expression('getKeywordsSpottingResults()'))
if isinstance(self.keywords_to_be_spotted, str):
_op.params['keywordsToBeSpotted'] = _op.expression(self.keywords_to_be_spotted)
elif isinstance(self.keywords_to_be_spotted, list):
Expand Down
2 changes: 1 addition & 1 deletion package/streamsx/sttgateway/tests/test_sttgateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def test_properties(self):
gateway.non_final_utterances_needed = True

res = files.map(gateway)
res.print()

# build only
self._build_only(name, topo)

Expand Down

0 comments on commit ac3b0ba

Please sign in to comment.