Skip to content

Commit

Permalink
quality: Use private vars name for SttClient
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlesne committed Jan 16, 2025
1 parent 75a9f0d commit 7a1861a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions app/helpers/call_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ async def __aenter__(self):
)()

# Create client
self.client = SpeechRecognizer(
self._client = SpeechRecognizer(
audio_config=AudioConfig(stream=self._stream),
language=self._call.lang.short_code,
speech_config=SpeechConfig(
Expand All @@ -626,24 +626,25 @@ async def __aenter__(self):
)

# TSS events
self.client.recognized.connect(self._complete_callback)
self.client.recognizing.connect(self._partial_callback)
self._client.recognized.connect(self._complete_callback)
self._client.recognizing.connect(self._partial_callback)

# Debugging events
self.client.canceled.connect(
self._client.canceled.connect(
lambda event: logger.warning("STT cancelled: %s", event)
)
self.client.session_started.connect(lambda _: logger.debug("STT started"))
self.client.session_stopped.connect(lambda _: logger.debug("STT stopped"))
self._client.session_started.connect(lambda _: logger.debug("STT started"))
self._client.session_stopped.connect(lambda _: logger.debug("STT stopped"))

# Start STT
self.client.start_continuous_recognition_async()
self._client.start_continuous_recognition_async()

return self

async def __aexit__(self, *args, **kwargs):
# Stop STT
self.client.stop_continuous_recognition_async()
if self._client:
self._client.stop_continuous_recognition_async()

def _partial_callback(self, event):
"""
Expand Down

0 comments on commit 7a1861a

Please sign in to comment.