fix: pass list-type Deepgram settings as lists instead of stringifying
List-valued settings like keyterm, keywords, search, redact, and replace were being converted to strings before being passed to the SDK connect() method. The SDK expects lists so its encode_query can produce repeated query params (keyterm=a&keyterm=b).
This commit is contained in:
1
changelog/4063.fixed.md
Normal file
1
changelog/4063.fixed.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- Fixed Deepgram STT list-type settings (`keyterm`, `keywords`, `search`, `redact`, `replace`) being stringified instead of passed as lists to the SDK, which caused them to be sent as literal strings (e.g. `"['pipecat']"`) in the WebSocket query params.
|
||||||
@@ -554,7 +554,15 @@ class DeepgramSTTService(STTService):
|
|||||||
value = getattr(s, f.name)
|
value = getattr(s, f.name)
|
||||||
if not is_given(value) or value is None:
|
if not is_given(value) or value is None:
|
||||||
continue
|
continue
|
||||||
kwargs[f.name] = str(value).lower() if isinstance(value, bool) else str(value)
|
# Lists (e.g. keyterm, keywords, search, redact, replace) must be
|
||||||
|
# passed through as-is so the SDK's encode_query produces repeated
|
||||||
|
# query params (keyterm=a&keyterm=b) instead of a stringified list.
|
||||||
|
if isinstance(value, list):
|
||||||
|
kwargs[f.name] = value
|
||||||
|
elif isinstance(value, bool):
|
||||||
|
kwargs[f.name] = str(value).lower()
|
||||||
|
else:
|
||||||
|
kwargs[f.name] = str(value)
|
||||||
|
|
||||||
# model and language
|
# model and language
|
||||||
if is_given(s.model) and s.model is not None:
|
if is_given(s.model) and s.model is not None:
|
||||||
@@ -580,7 +588,12 @@ class DeepgramSTTService(STTService):
|
|||||||
# Any remaining values in extra (that didn't map to declared fields)
|
# Any remaining values in extra (that didn't map to declared fields)
|
||||||
for key, value in s.extra.items():
|
for key, value in s.extra.items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
kwargs[key] = str(value).lower() if isinstance(value, bool) else str(value)
|
if isinstance(value, list):
|
||||||
|
kwargs[key] = value
|
||||||
|
elif isinstance(value, bool):
|
||||||
|
kwargs[key] = str(value).lower()
|
||||||
|
else:
|
||||||
|
kwargs[key] = str(value)
|
||||||
|
|
||||||
if self._addons:
|
if self._addons:
|
||||||
for key, value in self._addons.items():
|
for key, value in self._addons.items():
|
||||||
|
|||||||
Reference in New Issue
Block a user