swarmauri_agent_texttospeech 0.11.0.dev4__tar.gz → 0.11.0.dev5__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.
- {swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/PKG-INFO +45 -12
- {swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/README.md +42 -9
- {swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/pyproject.toml +7 -3
- {swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/swarmauri_agent_texttospeech/TextToSpeechAgent.py +34 -12
- {swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/LICENSE +0 -0
- {swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/swarmauri_agent_texttospeech/__init__.py +0 -0
{swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/PKG-INFO
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: swarmauri_agent_texttospeech
|
|
3
|
-
Version: 0.11.0.
|
|
3
|
+
Version: 0.11.0.dev5
|
|
4
4
|
Summary: Stateless Swarmauri agent for converting independent text prompts into audio through any TTSBase provider.
|
|
5
5
|
License-Expression: Apache-2.0
|
|
6
6
|
License-File: LICENSE
|
|
@@ -20,8 +20,8 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
20
20
|
Classifier: Programming Language :: Python :: 3.12
|
|
21
21
|
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
22
22
|
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
23
|
-
Requires-Dist: swarmauri_base
|
|
24
|
-
Requires-Dist: swarmauri_core
|
|
23
|
+
Requires-Dist: swarmauri_base (>=0.11.0.dev12,<0.12)
|
|
24
|
+
Requires-Dist: swarmauri_core (>=0.11.0.dev7,<0.12)
|
|
25
25
|
Description-Content-Type: text/markdown
|
|
26
26
|
|
|
27
27
|

|
|
@@ -55,16 +55,16 @@ uv add swarmauri_agent_texttospeech
|
|
|
55
55
|
pip install swarmauri_agent_texttospeech
|
|
56
56
|
```
|
|
57
57
|
|
|
58
|
-
Install a TTS provider package alongside the agent. For
|
|
58
|
+
Install a TTS provider package alongside the agent. For the alpha OpenAI provider:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
uv add
|
|
61
|
+
uv add --prerelease allow swarmauri_tts_openai
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
Or with `pip`:
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
|
-
pip install
|
|
67
|
+
pip install --pre swarmauri_tts_openai
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
## Usage
|
|
@@ -73,13 +73,12 @@ pip install swarmauri_tts_playht
|
|
|
73
73
|
import os
|
|
74
74
|
|
|
75
75
|
from swarmauri_agent_texttospeech import TextToSpeechAgent
|
|
76
|
-
from
|
|
76
|
+
from swarmauri_tts_openai import OpenaiTTS
|
|
77
77
|
|
|
78
|
-
tts =
|
|
79
|
-
api_key=os.environ["
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
voice="Adolfo",
|
|
78
|
+
tts = OpenaiTTS(
|
|
79
|
+
api_key=os.environ["OPENAI_API_KEY"],
|
|
80
|
+
name="gpt-4o-mini-tts",
|
|
81
|
+
voice="alloy",
|
|
83
82
|
)
|
|
84
83
|
agent = TextToSpeechAgent(tts=tts, output_path="greeting.mp3")
|
|
85
84
|
|
|
@@ -90,6 +89,40 @@ print(audio_path)
|
|
|
90
89
|
Each call is independent. The agent passes only that call's text to the TTS
|
|
91
90
|
provider and never constructs a conversation or system message.
|
|
92
91
|
|
|
92
|
+
## Structured dialogue and bounded batches
|
|
93
|
+
|
|
94
|
+
The agent also forwards a nonempty tuple of typed dialogue turns unchanged:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
import os
|
|
98
|
+
|
|
99
|
+
from swarmauri_agent_texttospeech import TextToSpeechAgent
|
|
100
|
+
from swarmauri_tts_gemini_dialogue import (
|
|
101
|
+
GeminiDialogueTTS, GeminiDialogueTurn,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
provider = GeminiDialogueTTS(
|
|
105
|
+
api_key=os.environ["GEMINI_API_KEY"],
|
|
106
|
+
speaker_voices={"A": "Puck", "B": "Kore"},
|
|
107
|
+
)
|
|
108
|
+
agent = TextToSpeechAgent(tts=provider, output_path="dialogue.wav")
|
|
109
|
+
turns = (
|
|
110
|
+
GeminiDialogueTurn(text="Hello", speaker="A"),
|
|
111
|
+
GeminiDialogueTurn(text="Hello back", speaker="B"),
|
|
112
|
+
)
|
|
113
|
+
agent.exec(turns)
|
|
114
|
+
# await agent.abatch([turns], max_concurrent=2)
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Speaker and voice validation belongs to the selected provider. A JSON string
|
|
118
|
+
is not parsed into turns. Set filenames to match the codec; Gemini/native
|
|
119
|
+
DeepInfra WAV defaults require .wav paths. Async batches default to at most
|
|
120
|
+
five concurrent calls, with a positive integer max_concurrent override.
|
|
121
|
+
|
|
122
|
+
The OpenAI Speech example above is temporary compatibility: its models have a
|
|
123
|
+
scheduled 2027-01-06 shutdown. All new provider packages remain alpha and live
|
|
124
|
+
verification is pending; see the SDK migration and verification guides.
|
|
125
|
+
|
|
93
126
|
## Contributing
|
|
94
127
|
|
|
95
128
|
This package is part of the
|
{swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/README.md
RENAMED
|
@@ -29,16 +29,16 @@ uv add swarmauri_agent_texttospeech
|
|
|
29
29
|
pip install swarmauri_agent_texttospeech
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
Install a TTS provider package alongside the agent. For
|
|
32
|
+
Install a TTS provider package alongside the agent. For the alpha OpenAI provider:
|
|
33
33
|
|
|
34
34
|
```bash
|
|
35
|
-
uv add
|
|
35
|
+
uv add --prerelease allow swarmauri_tts_openai
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
Or with `pip`:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
pip install
|
|
41
|
+
pip install --pre swarmauri_tts_openai
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## Usage
|
|
@@ -47,13 +47,12 @@ pip install swarmauri_tts_playht
|
|
|
47
47
|
import os
|
|
48
48
|
|
|
49
49
|
from swarmauri_agent_texttospeech import TextToSpeechAgent
|
|
50
|
-
from
|
|
50
|
+
from swarmauri_tts_openai import OpenaiTTS
|
|
51
51
|
|
|
52
|
-
tts =
|
|
53
|
-
api_key=os.environ["
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
voice="Adolfo",
|
|
52
|
+
tts = OpenaiTTS(
|
|
53
|
+
api_key=os.environ["OPENAI_API_KEY"],
|
|
54
|
+
name="gpt-4o-mini-tts",
|
|
55
|
+
voice="alloy",
|
|
57
56
|
)
|
|
58
57
|
agent = TextToSpeechAgent(tts=tts, output_path="greeting.mp3")
|
|
59
58
|
|
|
@@ -64,6 +63,40 @@ print(audio_path)
|
|
|
64
63
|
Each call is independent. The agent passes only that call's text to the TTS
|
|
65
64
|
provider and never constructs a conversation or system message.
|
|
66
65
|
|
|
66
|
+
## Structured dialogue and bounded batches
|
|
67
|
+
|
|
68
|
+
The agent also forwards a nonempty tuple of typed dialogue turns unchanged:
|
|
69
|
+
|
|
70
|
+
```python
|
|
71
|
+
import os
|
|
72
|
+
|
|
73
|
+
from swarmauri_agent_texttospeech import TextToSpeechAgent
|
|
74
|
+
from swarmauri_tts_gemini_dialogue import (
|
|
75
|
+
GeminiDialogueTTS, GeminiDialogueTurn,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
provider = GeminiDialogueTTS(
|
|
79
|
+
api_key=os.environ["GEMINI_API_KEY"],
|
|
80
|
+
speaker_voices={"A": "Puck", "B": "Kore"},
|
|
81
|
+
)
|
|
82
|
+
agent = TextToSpeechAgent(tts=provider, output_path="dialogue.wav")
|
|
83
|
+
turns = (
|
|
84
|
+
GeminiDialogueTurn(text="Hello", speaker="A"),
|
|
85
|
+
GeminiDialogueTurn(text="Hello back", speaker="B"),
|
|
86
|
+
)
|
|
87
|
+
agent.exec(turns)
|
|
88
|
+
# await agent.abatch([turns], max_concurrent=2)
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Speaker and voice validation belongs to the selected provider. A JSON string
|
|
92
|
+
is not parsed into turns. Set filenames to match the codec; Gemini/native
|
|
93
|
+
DeepInfra WAV defaults require .wav paths. Async batches default to at most
|
|
94
|
+
five concurrent calls, with a positive integer max_concurrent override.
|
|
95
|
+
|
|
96
|
+
The OpenAI Speech example above is temporary compatibility: its models have a
|
|
97
|
+
scheduled 2027-01-06 shutdown. All new provider packages remain alpha and live
|
|
98
|
+
verification is pending; see the SDK migration and verification guides.
|
|
99
|
+
|
|
67
100
|
## Contributing
|
|
68
101
|
|
|
69
102
|
This package is part of the
|
{swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/pyproject.toml
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "swarmauri_agent_texttospeech"
|
|
3
|
-
version = "0.11.0.
|
|
3
|
+
version = "0.11.0.dev5"
|
|
4
4
|
description = "Stateless Swarmauri agent for converting independent text prompts into audio through any TTSBase provider."
|
|
5
5
|
license = "Apache-2.0"
|
|
6
6
|
readme = "README.md"
|
|
@@ -22,8 +22,8 @@ classifiers = [
|
|
|
22
22
|
]
|
|
23
23
|
authors = [{ name = "Jacob Stewart", email = "jacob@swarmauri.com" }]
|
|
24
24
|
dependencies = [
|
|
25
|
-
"swarmauri_core",
|
|
26
|
-
"swarmauri_base",
|
|
25
|
+
"swarmauri_core>=0.11.0.dev7,<0.12",
|
|
26
|
+
"swarmauri_base>=0.11.0.dev12,<0.12",
|
|
27
27
|
]
|
|
28
28
|
keywords = [
|
|
29
29
|
"swarmauri",
|
|
@@ -39,6 +39,8 @@ keywords = [
|
|
|
39
39
|
[tool.uv.sources]
|
|
40
40
|
swarmauri_core = { workspace = true }
|
|
41
41
|
swarmauri_base = { workspace = true }
|
|
42
|
+
swarmauri_tts_elevenlabs_dialogue = { workspace = true }
|
|
43
|
+
swarmauri_tts_gemini_dialogue = { workspace = true }
|
|
42
44
|
|
|
43
45
|
[project.entry-points.'swarmauri.agents']
|
|
44
46
|
TextToSpeechAgent = "swarmauri_agent_texttospeech:TextToSpeechAgent"
|
|
@@ -54,6 +56,8 @@ build-backend = "poetry.core.masonry.api"
|
|
|
54
56
|
|
|
55
57
|
[dependency-groups]
|
|
56
58
|
dev = [
|
|
59
|
+
"swarmauri_tts_elevenlabs_dialogue>=0.1.0a1,<0.2",
|
|
60
|
+
"swarmauri_tts_gemini_dialogue>=0.1.0a1,<0.2",
|
|
57
61
|
"pytest>=8.0",
|
|
58
62
|
"pytest-asyncio>=0.24.0",
|
|
59
63
|
"ruff>=0.9.9",
|
|
@@ -7,7 +7,7 @@ from collections.abc import Sequence
|
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
from typing import Any, Dict, List, Literal, Optional, Union
|
|
9
9
|
|
|
10
|
-
from pydantic import ConfigDict, Field
|
|
10
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
11
11
|
|
|
12
12
|
from swarmauri_base.ComponentBase import ComponentBase, SubclassUnion
|
|
13
13
|
from swarmauri_base.agents.AgentBase import AgentBase
|
|
@@ -41,7 +41,7 @@ class TextToSpeechAgent(AgentBase):
|
|
|
41
41
|
|
|
42
42
|
def exec(
|
|
43
43
|
self,
|
|
44
|
-
input_str: Optional[Union[str, IMessage]] = "",
|
|
44
|
+
input_str: Optional[Union[str, IMessage, tuple[BaseModel, ...]]] = "",
|
|
45
45
|
llm_kwargs: Optional[Dict] = None,
|
|
46
46
|
*,
|
|
47
47
|
audio_path: Optional[str] = None,
|
|
@@ -58,7 +58,7 @@ class TextToSpeechAgent(AgentBase):
|
|
|
58
58
|
|
|
59
59
|
async def aexec(
|
|
60
60
|
self,
|
|
61
|
-
input_str: Optional[Union[str, IMessage]] = "",
|
|
61
|
+
input_str: Optional[Union[str, IMessage, tuple[BaseModel, ...]]] = "",
|
|
62
62
|
llm_kwargs: Optional[Dict] = None,
|
|
63
63
|
*,
|
|
64
64
|
audio_path: Optional[str] = None,
|
|
@@ -75,7 +75,7 @@ class TextToSpeechAgent(AgentBase):
|
|
|
75
75
|
|
|
76
76
|
def batch(
|
|
77
77
|
self,
|
|
78
|
-
inputs: List[Union[str, IMessage]],
|
|
78
|
+
inputs: List[Union[str, IMessage, tuple[BaseModel, ...]]],
|
|
79
79
|
llm_kwargs: Optional[Dict] = None,
|
|
80
80
|
*,
|
|
81
81
|
audio_paths: Optional[Sequence[str]] = None,
|
|
@@ -95,35 +95,57 @@ class TextToSpeechAgent(AgentBase):
|
|
|
95
95
|
|
|
96
96
|
async def abatch(
|
|
97
97
|
self,
|
|
98
|
-
inputs: List[Union[str, IMessage]],
|
|
98
|
+
inputs: List[Union[str, IMessage, tuple[BaseModel, ...]]],
|
|
99
99
|
llm_kwargs: Optional[Dict] = None,
|
|
100
100
|
*,
|
|
101
101
|
audio_paths: Optional[Sequence[str]] = None,
|
|
102
102
|
tts_kwargs: Optional[Dict[str, Any]] = None,
|
|
103
|
+
max_concurrent: int = 5,
|
|
103
104
|
) -> List[str]:
|
|
104
|
-
"""
|
|
105
|
+
"""Synthesize independent inputs with bounded concurrency."""
|
|
106
|
+
if (
|
|
107
|
+
isinstance(max_concurrent, bool)
|
|
108
|
+
or not isinstance(max_concurrent, int)
|
|
109
|
+
or max_concurrent < 1
|
|
110
|
+
):
|
|
111
|
+
raise ValueError("max_concurrent must be a positive integer.")
|
|
105
112
|
paths = self._resolve_batch_paths(len(inputs), audio_paths)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
113
|
+
semaphore = asyncio.Semaphore(max_concurrent)
|
|
114
|
+
|
|
115
|
+
async def generate(input_data, path):
|
|
116
|
+
async with semaphore:
|
|
117
|
+
return await self.aexec(
|
|
109
118
|
input_data,
|
|
110
119
|
llm_kwargs=llm_kwargs,
|
|
111
120
|
audio_path=path,
|
|
112
121
|
tts_kwargs=tts_kwargs,
|
|
113
122
|
)
|
|
123
|
+
|
|
124
|
+
return await asyncio.gather(
|
|
125
|
+
*(
|
|
126
|
+
generate(input_data, path)
|
|
114
127
|
for input_data, path in zip(inputs, paths)
|
|
115
|
-
|
|
128
|
+
)
|
|
116
129
|
)
|
|
117
130
|
|
|
118
131
|
@staticmethod
|
|
119
|
-
def _input_text(
|
|
132
|
+
def _input_text(
|
|
133
|
+
input_data: Optional[Union[str, IMessage, tuple[BaseModel, ...]]],
|
|
134
|
+
) -> Union[str, tuple[BaseModel, ...]]:
|
|
135
|
+
if (
|
|
136
|
+
isinstance(input_data, tuple)
|
|
137
|
+
and input_data
|
|
138
|
+
and all(isinstance(turn, BaseModel) for turn in input_data)
|
|
139
|
+
):
|
|
140
|
+
return input_data
|
|
120
141
|
if isinstance(input_data, str):
|
|
121
142
|
text = input_data
|
|
122
143
|
elif isinstance(input_data, IMessage):
|
|
123
144
|
text = input_data.content
|
|
124
145
|
else:
|
|
125
146
|
raise TypeError(
|
|
126
|
-
"Input must be text
|
|
147
|
+
"Input must be text, an IMessage, "
|
|
148
|
+
"or a nonempty tuple of typed dialogue turns."
|
|
127
149
|
)
|
|
128
150
|
|
|
129
151
|
if not isinstance(text, str):
|
{swarmauri_agent_texttospeech-0.11.0.dev4 → swarmauri_agent_texttospeech-0.11.0.dev5}/LICENSE
RENAMED
|
File without changes
|