livekit-plugins-azure 1.0.0rc9__py3-none-any.whl → 1.0.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,13 @@ from dataclasses import dataclass
21
21
 
22
22
  import azure.cognitiveservices.speech as speechsdk # type: ignore
23
23
  from livekit import rtc
24
- from livekit.agents import DEFAULT_API_CONNECT_OPTIONS, APIConnectOptions, stt, utils
24
+ from livekit.agents import (
25
+ DEFAULT_API_CONNECT_OPTIONS,
26
+ APIConnectionError,
27
+ APIConnectOptions,
28
+ stt,
29
+ utils,
30
+ )
25
31
  from livekit.agents.types import (
26
32
  NOT_GIVEN,
27
33
  NotGivenOr,
@@ -65,12 +71,15 @@ class STT(stt.STT):
65
71
  # Azure handles multiple languages and can auto-detect the language used. It requires the candidate set to be set. # noqa: E501
66
72
  language: NotGivenOr[str | list[str] | None] = NOT_GIVEN,
67
73
  profanity: NotGivenOr[speechsdk.enums.ProfanityOption] = NOT_GIVEN,
74
+ speech_endpoint: NotGivenOr[str] = NOT_GIVEN,
68
75
  ):
69
76
  """
70
77
  Create a new instance of Azure STT.
71
78
 
72
79
  Either ``speech_host`` or ``speech_key`` and ``speech_region`` or
73
- ``speech_auth_token`` and ``speech_region`` must be set using arguments.
80
+ ``speech_auth_token`` and ``speech_region`` or
81
+ ``speech_key`` and ``speech_endpoint``
82
+ must be set using arguments.
74
83
  Alternatively, set the ``AZURE_SPEECH_HOST``, ``AZURE_SPEECH_KEY``
75
84
  and ``AZURE_SPEECH_REGION`` environmental variables, respectively.
76
85
  ``speech_auth_token`` must be set using the arguments as it's an ephemeral token.
@@ -96,9 +105,10 @@ class STT(stt.STT):
96
105
  is_given(speech_host)
97
106
  or (is_given(speech_key) and is_given(speech_region))
98
107
  or (is_given(speech_auth_token) and is_given(speech_region))
108
+ or (is_given(speech_key) and is_given(speech_endpoint))
99
109
  ):
100
110
  raise ValueError(
101
- "AZURE_SPEECH_HOST or AZURE_SPEECH_KEY and AZURE_SPEECH_REGION or speech_auth_token and AZURE_SPEECH_REGION must be set" # noqa: E501
111
+ "AZURE_SPEECH_HOST or AZURE_SPEECH_KEY and AZURE_SPEECH_REGION or speech_auth_token and AZURE_SPEECH_REGION or AZURE_SPEECH_KEY and speech_endpoint must be set" # noqa: E501
102
112
  )
103
113
 
104
114
  self._config = STTOptions(
@@ -113,6 +123,7 @@ class STT(stt.STT):
113
123
  segmentation_max_time_ms=segmentation_max_time_ms,
114
124
  segmentation_strategy=segmentation_strategy,
115
125
  profanity=profanity,
126
+ speech_endpoint=speech_endpoint,
116
127
  )
117
128
  self._streams = weakref.WeakSet[SpeechStream]()
118
129
 
@@ -193,15 +204,20 @@ class SpeechStream(stt.SpeechStream):
193
204
 
194
205
  process_input_task = asyncio.create_task(process_input())
195
206
  wait_reconnect_task = asyncio.create_task(self._reconnect_event.wait())
207
+ wait_stopped_task = asyncio.create_task(self._session_stopped_event.wait())
196
208
 
197
209
  try:
198
210
  done, _ = await asyncio.wait(
199
- [process_input_task, wait_reconnect_task],
211
+ [process_input_task, wait_reconnect_task, wait_stopped_task],
200
212
  return_when=asyncio.FIRST_COMPLETED,
201
213
  )
202
214
  for task in done:
203
- if task != wait_reconnect_task:
215
+ if task not in [wait_reconnect_task, wait_stopped_task]:
204
216
  task.result()
217
+
218
+ if wait_stopped_task in done:
219
+ raise APIConnectionError("SpeechRecognition session stopped")
220
+
205
221
  if wait_reconnect_task not in done:
206
222
  break
207
223
  self._reconnect_event.clear()
@@ -172,6 +172,7 @@ class TTS(tts.TTS):
172
172
  on_synthesizing_event: NotGivenOr[Callable] = NOT_GIVEN,
173
173
  on_viseme_event: NotGivenOr[Callable] = NOT_GIVEN,
174
174
  on_word_boundary_event: NotGivenOr[Callable] = NOT_GIVEN,
175
+ speech_endpoint: NotGivenOr[str] = NOT_GIVEN,
175
176
  ) -> None:
176
177
  """
177
178
  Create a new instance of Azure TTS.
@@ -209,9 +210,10 @@ class TTS(tts.TTS):
209
210
  is_given(speech_host)
210
211
  or (is_given(speech_key) and is_given(speech_region))
211
212
  or (is_given(speech_auth_token) and is_given(speech_region))
213
+ or (is_given(speech_key) and is_given(speech_endpoint))
212
214
  ):
213
215
  raise ValueError(
214
- "AZURE_SPEECH_HOST or AZURE_SPEECH_KEY and AZURE_SPEECH_REGION or speech_auth_token and AZURE_SPEECH_REGION must be set" # noqa: E501
216
+ "AZURE_SPEECH_HOST or AZURE_SPEECH_KEY and AZURE_SPEECH_REGION or speech_auth_token and AZURE_SPEECH_REGION or AZURE_SPEECH_KEY and speech_endpoint must be set" # noqa: E501
215
217
  )
216
218
 
217
219
  if is_given(prosody):
@@ -238,6 +240,7 @@ class TTS(tts.TTS):
238
240
  on_synthesizing_event=on_synthesizing_event,
239
241
  on_viseme_event=on_viseme_event,
240
242
  on_word_boundary_event=on_word_boundary_event,
243
+ speech_endpoint=speech_endpoint,
241
244
  )
242
245
 
243
246
  def update_options(
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = '1.0.0.rc9'
15
+ __version__ = '1.0.2'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: livekit-plugins-azure
3
- Version: 1.0.0rc9
3
+ Version: 1.0.2
4
4
  Summary: Agent Framework plugin for services from Azure
5
5
  Project-URL: Documentation, https://docs.livekit.io
6
6
  Project-URL: Website, https://livekit.io/
@@ -19,7 +19,7 @@ Classifier: Topic :: Multimedia :: Video
19
19
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
20
  Requires-Python: >=3.9.0
21
21
  Requires-Dist: azure-cognitiveservices-speech>=1.41.0
22
- Requires-Dist: livekit-agents>=1.0.0.rc9
22
+ Requires-Dist: livekit-agents>=1.0.2
23
23
  Description-Content-Type: text/markdown
24
24
 
25
25
  # LiveKit Plugins Azure
@@ -0,0 +1,9 @@
1
+ livekit/plugins/azure/__init__.py,sha256=8YPW1EAltd4oip3WItsMy17EMekroUzTPLFRIwLP2Wc,1082
2
+ livekit/plugins/azure/log.py,sha256=MeD0unQJ72aDc9K8zUi9LgUBls6h2WUALryOjAumrKs,68
3
+ livekit/plugins/azure/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
+ livekit/plugins/azure/stt.py,sha256=vEB5w03F4dyu_BxQ849JMRgGuzTMNmtLDlUvWi44fvQ,14150
5
+ livekit/plugins/azure/tts.py,sha256=e4BccMEnx7Qukij5t1H47w6XzFLeZIPlUVhjZ5yJAFg,19280
6
+ livekit/plugins/azure/version.py,sha256=RSUx0PwRR34jaRRP_sG9HJWmSKxdazVULy4BLENZ3S8,600
7
+ livekit_plugins_azure-1.0.2.dist-info/METADATA,sha256=qGEOeAh85HNRVZvosLOlUHwwBip3xP-aTF4P6FiAdv0,1394
8
+ livekit_plugins_azure-1.0.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
+ livekit_plugins_azure-1.0.2.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- livekit/plugins/azure/__init__.py,sha256=8YPW1EAltd4oip3WItsMy17EMekroUzTPLFRIwLP2Wc,1082
2
- livekit/plugins/azure/log.py,sha256=MeD0unQJ72aDc9K8zUi9LgUBls6h2WUALryOjAumrKs,68
3
- livekit/plugins/azure/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- livekit/plugins/azure/stt.py,sha256=TdjTMwSNlVBnrY6IB8ndS7OLuVOJtV1o3O7O4Vlnmsw,13566
5
- livekit/plugins/azure/tts.py,sha256=A2x7f1iS7dTZij1K7FoVILynfU1YGQiwG5venknrfXo,19073
6
- livekit/plugins/azure/version.py,sha256=_0m64Sw2cs3YI-DUoRXhekToRoCXFqqShFV-7Dvs3jo,604
7
- livekit_plugins_azure-1.0.0rc9.dist-info/METADATA,sha256=Ihk8M4HZfDbUOZgNjeTX7UHcZMRJWkDjsVaMQEimbs8,1401
8
- livekit_plugins_azure-1.0.0rc9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
9
- livekit_plugins_azure-1.0.0rc9.dist-info/RECORD,,