livekit-plugins-neuphonic 0.1.0__py3-none-any.whl → 0.1.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.
@@ -130,7 +130,7 @@ class TTS(tts.TTS):
130
130
  encoding (TTSEncodings | str, optional): The audio encoding format. Defaults to "pcm_mulaw".
131
131
  speed (float, optional): The audio playback speed. Defaults to 1.0.
132
132
  sample_rate (int, optional): The audio sample rate in Hz. Defaults to 22050.
133
- api_key (str | None, optional): The Neuphonic API key. If not provided, it will be read from the NEUPHONIC_API_TOKEN environment variable.
133
+ api_key (str | None, optional): The Neuphonic API key. If not provided, it will be read from the NEUPHONIC_API_KEY environment variable.
134
134
  http_session (aiohttp.ClientSession | None, optional): An existing aiohttp ClientSession to use. If not provided, a new session will be created.
135
135
  base_url (str, optional): The base URL for the Neuphonic API. Defaults to "api.neuphonic.com".
136
136
  """
@@ -140,10 +140,12 @@ class TTS(tts.TTS):
140
140
  num_channels=NUM_CHANNELS,
141
141
  )
142
142
 
143
- api_key = api_key or os.environ.get("NEUPHONIC_API_TOKEN")
143
+ api_key = api_key or os.environ.get("NEUPHONIC_API_KEY")
144
144
 
145
145
  if not api_key:
146
- raise ValueError("NEUPHONIC_API_TOKEN must be set")
146
+ raise ValueError(
147
+ "NEUPHONIC_API_KEY must be set using the argument or by setting the NEUPHONIC_API_KEY environment variable."
148
+ )
147
149
 
148
150
  self._opts = _TTSOptions(
149
151
  model=model,
@@ -346,26 +348,6 @@ class SynthesizeStream(tts.SynthesizeStream):
346
348
 
347
349
  async def _run(self) -> None:
348
350
  request_id = utils.shortuuid()
349
- request_data = {request_id: {"sent": "", "recv": ""}}
350
-
351
- def _is_all_audio_recv():
352
- """Check whether all audio has been recieved."""
353
- recv_text = (
354
- request_data[request_id]["recv"]
355
- .lower()
356
- .replace(" ", "")
357
- .replace("\n", "")
358
- .replace("<stop>", "")
359
- )
360
- sent_text = (
361
- request_data[request_id]["sent"]
362
- .lower()
363
- .replace(" ", "")
364
- .replace("\n", "")
365
- .replace("<stop>", "")
366
- )
367
-
368
- return sent_text == recv_text
369
351
 
370
352
  async def _send_task(ws: aiohttp.ClientWebSocketResponse):
371
353
  """Stream text to the websocket."""
@@ -376,7 +358,6 @@ class SynthesizeStream(tts.SynthesizeStream):
376
358
  await ws.send_str(json.dumps({"text": "<STOP>"}))
377
359
  continue
378
360
 
379
- request_data[request_id]["sent"] += data
380
361
  await ws.send_str(json.dumps({"text": data}))
381
362
 
382
363
  async def _recv_task(ws: aiohttp.ClientWebSocketResponse):
@@ -409,20 +390,19 @@ class SynthesizeStream(tts.SynthesizeStream):
409
390
 
410
391
  if data.get("data"):
411
392
  b64data = base64.b64decode(data["data"]["audio"])
412
- recv_text = data["data"]["text"]
413
393
  for frame in audio_bstream.write(b64data):
414
394
  emitter.push(frame)
415
395
 
416
- request_data[request_id]["recv"] += recv_text
396
+ if data["data"].get(
397
+ "stop"
398
+ ): # A bool flag, is True when audio reaches "<STOP>"
399
+ for frame in audio_bstream.flush():
400
+ emitter.push(frame)
401
+ emitter.flush()
402
+ break # we are not going to receive any more audio
417
403
  else:
418
404
  logger.error("Unexpected Neuphonic message %s", data)
419
405
 
420
- if _is_all_audio_recv():
421
- for frame in audio_bstream.flush():
422
- emitter.push(frame)
423
- emitter.flush()
424
- break # we are not going to receive any more audio
425
-
426
406
  async with self._pool.connection() as ws:
427
407
  tasks = [
428
408
  asyncio.create_task(_send_task(ws)),
@@ -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__ = "0.1.0"
15
+ __version__ = "0.1.2"
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: livekit-plugins-neuphonic
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: LiveKit Agents Plugin for Neuphonic
5
5
  Home-page: https://github.com/livekit/agents
6
6
  License: Apache-2.0
@@ -19,7 +19,7 @@ Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3 :: Only
20
20
  Requires-Python: >=3.9.0
21
21
  Description-Content-Type: text/markdown
22
- Requires-Dist: livekit-agents<1.0.0,>=0.12.16
22
+ Requires-Dist: livekit-agents<1.0.0,>=0.12.20
23
23
  Dynamic: classifier
24
24
  Dynamic: description
25
25
  Dynamic: description-content-type
@@ -43,4 +43,4 @@ pip install livekit-plugins-neuphonic
43
43
 
44
44
  ## Pre-requisites
45
45
 
46
- You'll need an API key from Neuphonic. It can be set as an environment variable: `NEUPHONIC_API_TOKEN`
46
+ You'll need an API key from Neuphonic. It can be set as an environment variable: `NEUPHONIC_API_KEY`
@@ -0,0 +1,10 @@
1
+ livekit/plugins/neuphonic/__init__.py,sha256=mJnPVLsKAdUkdWuHWd16A0n2vsVBi3GjgNmB8gv9jjI,1097
2
+ livekit/plugins/neuphonic/log.py,sha256=rAHz71IcbvPkixndXBVffPQsmWUKTLqRaYRuPIxO29w,72
3
+ livekit/plugins/neuphonic/models.py,sha256=Svfn_sWA3Q2ZXsPBXY-K5hslq5FE62hvyXBES2C3aSc,201
4
+ livekit/plugins/neuphonic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ livekit/plugins/neuphonic/tts.py,sha256=NvFgIgig9sNAUS5qBFQq3PHBX-RoSgt_HF01okVOmss,14137
6
+ livekit/plugins/neuphonic/version.py,sha256=S3xxF-H96nScSv_7l7IUvROJ0avu9oz5Gm6j673md_Y,600
7
+ livekit_plugins_neuphonic-0.1.2.dist-info/METADATA,sha256=oSAGd-KZUiL3Ks4-s1p8-CbL8HdGcIA5pGMLZFCPvXg,1478
8
+ livekit_plugins_neuphonic-0.1.2.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
9
+ livekit_plugins_neuphonic-0.1.2.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
+ livekit_plugins_neuphonic-0.1.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.0.0)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,10 +0,0 @@
1
- livekit/plugins/neuphonic/__init__.py,sha256=mJnPVLsKAdUkdWuHWd16A0n2vsVBi3GjgNmB8gv9jjI,1097
2
- livekit/plugins/neuphonic/log.py,sha256=rAHz71IcbvPkixndXBVffPQsmWUKTLqRaYRuPIxO29w,72
3
- livekit/plugins/neuphonic/models.py,sha256=Svfn_sWA3Q2ZXsPBXY-K5hslq5FE62hvyXBES2C3aSc,201
4
- livekit/plugins/neuphonic/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- livekit/plugins/neuphonic/tts.py,sha256=FFLDghnve_Mrx-0qfEYb4o_Bs8VNnZqAsQNI-M6Zxkw,14736
6
- livekit/plugins/neuphonic/version.py,sha256=vQH9cItKAVYAmrLbOntkbLqmxrUZrPiKb1TjkZ8jRKQ,600
7
- livekit_plugins_neuphonic-0.1.0.dist-info/METADATA,sha256=Q7Skn-28cnC318qr28oepZyaWnQ9etIO-H2c7D-M9jo,1480
8
- livekit_plugins_neuphonic-0.1.0.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
9
- livekit_plugins_neuphonic-0.1.0.dist-info/top_level.txt,sha256=OoDok3xUmXbZRvOrfvvXB-Juu4DX79dlq188E19YHoo,8
10
- livekit_plugins_neuphonic-0.1.0.dist-info/RECORD,,