videosdk-plugins-openai 0.0.20__tar.gz → 0.0.21__tar.gz
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.
Potentially problematic release.
This version of videosdk-plugins-openai might be problematic. Click here for more details.
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/PKG-INFO +2 -2
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/pyproject.toml +1 -1
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/tts.py +22 -1
- videosdk_plugins_openai-0.0.21/videosdk/plugins/openai/version.py +1 -0
- videosdk_plugins_openai-0.0.20/videosdk/plugins/openai/version.py +0 -1
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/.gitignore +0 -0
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/README.md +0 -0
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/__init__.py +0 -0
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/llm.py +0 -0
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/realtime_api.py +0 -0
- {videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/stt.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: videosdk-plugins-openai
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.21
|
|
4
4
|
Summary: VideoSDK Agent Framework plugin for OpenAI services
|
|
5
5
|
Author: videosdk
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -13,7 +13,7 @@ Classifier: Topic :: Multimedia :: Video
|
|
|
13
13
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
14
14
|
Requires-Python: >=3.11
|
|
15
15
|
Requires-Dist: openai[realtime]>=1.68.2
|
|
16
|
-
Requires-Dist: videosdk-agents>=0.0.
|
|
16
|
+
Requires-Dist: videosdk-agents>=0.0.21
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
19
19
|
# VideoSDK OpenAI Plugin
|
{videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/tts.py
RENAMED
|
@@ -4,6 +4,7 @@ from typing import Any, AsyncIterator, Literal, Optional, Union
|
|
|
4
4
|
import httpx
|
|
5
5
|
import os
|
|
6
6
|
import openai
|
|
7
|
+
import asyncio
|
|
7
8
|
|
|
8
9
|
from videosdk.agents import TTS
|
|
9
10
|
|
|
@@ -81,6 +82,7 @@ class OpenAITTS(TTS):
|
|
|
81
82
|
self.emit("error", "Audio track or event loop not set")
|
|
82
83
|
return
|
|
83
84
|
|
|
85
|
+
audio_data = b""
|
|
84
86
|
async with self._client.audio.speech.with_streaming_response.create(
|
|
85
87
|
model=self.model,
|
|
86
88
|
voice=voice_id or self.voice,
|
|
@@ -91,13 +93,32 @@ class OpenAITTS(TTS):
|
|
|
91
93
|
) as response:
|
|
92
94
|
async for chunk in response.iter_bytes():
|
|
93
95
|
if chunk:
|
|
94
|
-
|
|
96
|
+
audio_data += chunk
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if audio_data:
|
|
100
|
+
await self._stream_audio_chunks(audio_data)
|
|
95
101
|
|
|
96
102
|
except openai.APIError as e:
|
|
97
103
|
self.emit("error", str(e))
|
|
98
104
|
except Exception as e:
|
|
99
105
|
self.emit("error", f"TTS synthesis failed: {str(e)}")
|
|
100
106
|
|
|
107
|
+
async def _stream_audio_chunks(self, audio_bytes: bytes) -> None:
|
|
108
|
+
"""Stream audio data in chunks for smooth playback"""
|
|
109
|
+
chunk_size = int(OPENAI_TTS_SAMPLE_RATE * OPENAI_TTS_CHANNELS * 2 * 20 / 1000)
|
|
110
|
+
|
|
111
|
+
for i in range(0, len(audio_bytes), chunk_size):
|
|
112
|
+
chunk = audio_bytes[i:i + chunk_size]
|
|
113
|
+
|
|
114
|
+
if len(chunk) < chunk_size and len(chunk) > 0:
|
|
115
|
+
padding_needed = chunk_size - len(chunk)
|
|
116
|
+
chunk += b'\x00' * padding_needed
|
|
117
|
+
|
|
118
|
+
if len(chunk) == chunk_size:
|
|
119
|
+
self.loop.create_task(self.audio_track.add_new_bytes(chunk))
|
|
120
|
+
await asyncio.sleep(0.001)
|
|
121
|
+
|
|
101
122
|
async def aclose(self) -> None:
|
|
102
123
|
"""Cleanup resources"""
|
|
103
124
|
await self._client.close()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.21"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.20"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/llm.py
RENAMED
|
File without changes
|
|
File without changes
|
{videosdk_plugins_openai-0.0.20 → videosdk_plugins_openai-0.0.21}/videosdk/plugins/openai/stt.py
RENAMED
|
File without changes
|