deepctl-cmd-speak 0.0.2__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.
- deepctl_cmd_speak-0.0.2/PKG-INFO +63 -0
- deepctl_cmd_speak-0.0.2/README.md +42 -0
- deepctl_cmd_speak-0.0.2/pyproject.toml +40 -0
- deepctl_cmd_speak-0.0.2/setup.cfg +4 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak/__init__.py +1 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak/command.py +185 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak/models.py +11 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak.egg-info/PKG-INFO +63 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak.egg-info/SOURCES.txt +11 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak.egg-info/dependency_links.txt +1 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak.egg-info/entry_points.txt +2 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak.egg-info/requires.txt +4 -0
- deepctl_cmd_speak-0.0.2/src/deepctl_cmd_speak.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepctl-cmd-speak
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Speak (text-to-speech) command for deepctl
|
|
5
|
+
Author-email: Deepgram <devrel@deepgram.com>
|
|
6
|
+
Maintainer-email: Deepgram <devrel@deepgram.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: deepgram,cli,tts,text-to-speech,speak
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: deepctl-core>=0.1.10
|
|
18
|
+
Requires-Dist: click>=8.0.0
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
|
|
22
|
+
# deepctl-cmd-speak
|
|
23
|
+
|
|
24
|
+
> Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
|
|
25
|
+
|
|
26
|
+
Speak (text-to-speech) command for deepctl
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
This package is included with deepctl and does not need to be installed separately.
|
|
31
|
+
|
|
32
|
+
### Install deepctl
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install with pip
|
|
36
|
+
pip install deepctl
|
|
37
|
+
|
|
38
|
+
# Or install with uv
|
|
39
|
+
uv tool install deepctl
|
|
40
|
+
|
|
41
|
+
# Or install with pipx
|
|
42
|
+
pipx install deepctl
|
|
43
|
+
|
|
44
|
+
# Or run without installing
|
|
45
|
+
uvx deepctl --help
|
|
46
|
+
pipx run deepctl --help
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
| Command | Entry Point |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `deepctl speak` | `deepctl_cmd_speak.command:SpeakCommand` |
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
|
|
57
|
+
- `click>=8.0.0`
|
|
58
|
+
- `rich>=13.0.0`
|
|
59
|
+
- `pydantic>=2.0.0`
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT — see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# deepctl-cmd-speak
|
|
2
|
+
|
|
3
|
+
> Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
|
|
4
|
+
|
|
5
|
+
Speak (text-to-speech) command for deepctl
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
This package is included with deepctl and does not need to be installed separately.
|
|
10
|
+
|
|
11
|
+
### Install deepctl
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Install with pip
|
|
15
|
+
pip install deepctl
|
|
16
|
+
|
|
17
|
+
# Or install with uv
|
|
18
|
+
uv tool install deepctl
|
|
19
|
+
|
|
20
|
+
# Or install with pipx
|
|
21
|
+
pipx install deepctl
|
|
22
|
+
|
|
23
|
+
# Or run without installing
|
|
24
|
+
uvx deepctl --help
|
|
25
|
+
pipx run deepctl --help
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Commands
|
|
29
|
+
|
|
30
|
+
| Command | Entry Point |
|
|
31
|
+
|---------|-------------|
|
|
32
|
+
| `deepctl speak` | `deepctl_cmd_speak.command:SpeakCommand` |
|
|
33
|
+
|
|
34
|
+
## Dependencies
|
|
35
|
+
|
|
36
|
+
- `click>=8.0.0`
|
|
37
|
+
- `rich>=13.0.0`
|
|
38
|
+
- `pydantic>=2.0.0`
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT — see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "deepctl-cmd-speak"
|
|
7
|
+
version = "0.0.2" # x-release-please-version
|
|
8
|
+
description = "Speak (text-to-speech) command for deepctl"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
|
|
12
|
+
maintainers = [{ name = "Deepgram", email = "devrel@deepgram.com" }]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 3 - Alpha",
|
|
15
|
+
"Intended Audience :: Developers",
|
|
16
|
+
"Programming Language :: Python :: 3",
|
|
17
|
+
"Programming Language :: Python :: 3.10",
|
|
18
|
+
"Programming Language :: Python :: 3.11",
|
|
19
|
+
"Programming Language :: Python :: 3.12",
|
|
20
|
+
]
|
|
21
|
+
keywords = ["deepgram", "cli", "tts", "text-to-speech", "speak"]
|
|
22
|
+
requires-python = ">=3.10"
|
|
23
|
+
dependencies = [
|
|
24
|
+
"deepctl-core>=0.1.10",
|
|
25
|
+
"click>=8.0.0",
|
|
26
|
+
"rich>=13.0.0",
|
|
27
|
+
"pydantic>=2.0.0",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.scripts]
|
|
31
|
+
|
|
32
|
+
[project.entry-points."deepctl.commands"]
|
|
33
|
+
speak = "deepctl_cmd_speak.command:SpeakCommand"
|
|
34
|
+
|
|
35
|
+
[tool.setuptools]
|
|
36
|
+
package-dir = { "" = "src" }
|
|
37
|
+
|
|
38
|
+
[tool.setuptools.packages.find]
|
|
39
|
+
where = ["src"]
|
|
40
|
+
include = ["deepctl_cmd_speak*"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Speak (text-to-speech) command for deepctl."""
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"""Speak (text-to-speech) command for deepctl."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import sys
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from deepctl_core import (
|
|
10
|
+
AuthManager,
|
|
11
|
+
BaseCommand,
|
|
12
|
+
BaseResult,
|
|
13
|
+
Config,
|
|
14
|
+
DeepgramClient,
|
|
15
|
+
)
|
|
16
|
+
from rich.console import Console
|
|
17
|
+
|
|
18
|
+
from .models import SpeakResult
|
|
19
|
+
|
|
20
|
+
console = Console(stderr=True)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class SpeakCommand(BaseCommand):
|
|
24
|
+
"""Command for generating speech from text using Deepgram TTS."""
|
|
25
|
+
|
|
26
|
+
name = "speak"
|
|
27
|
+
help = "Convert text to speech using Deepgram TTS"
|
|
28
|
+
short_help = "Text-to-speech"
|
|
29
|
+
|
|
30
|
+
requires_auth = True
|
|
31
|
+
requires_project = False
|
|
32
|
+
ci_friendly = True
|
|
33
|
+
|
|
34
|
+
examples = [
|
|
35
|
+
'dg speak "Hello world"',
|
|
36
|
+
'dg speak "Hello world" -o hello.mp3',
|
|
37
|
+
"dg speak --file message.txt -o output.mp3",
|
|
38
|
+
'echo "Hello" | dg speak -o hello.mp3',
|
|
39
|
+
'dg speak "Hello" | ffplay -nodisp -',
|
|
40
|
+
'dg speak "Hello" -m aura-2-luna-en -o hello.wav --encoding linear16 --container wav',
|
|
41
|
+
]
|
|
42
|
+
agent_help = (
|
|
43
|
+
"Convert text to speech using Deepgram's TTS API. "
|
|
44
|
+
"Text can be provided as an argument, from a file, or piped via stdin. "
|
|
45
|
+
"Audio is written to a file (--output) or stdout for piping. "
|
|
46
|
+
"Supports model selection and audio format options."
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
def get_arguments(self) -> list[dict[str, Any]]:
|
|
50
|
+
return [
|
|
51
|
+
{
|
|
52
|
+
"name": "text",
|
|
53
|
+
"help": "Text to convert to speech",
|
|
54
|
+
"required": False,
|
|
55
|
+
"default": None,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"names": ["--output", "-o"],
|
|
59
|
+
"help": "Output file path (required if stdout is a terminal)",
|
|
60
|
+
"type": str,
|
|
61
|
+
"is_option": True,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"names": ["--model", "-m"],
|
|
65
|
+
"help": "TTS model (default: aura-2-asteria-en)",
|
|
66
|
+
"type": str,
|
|
67
|
+
"is_option": True,
|
|
68
|
+
"default": "aura-2-asteria-en",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"names": ["--encoding"],
|
|
72
|
+
"help": "Audio encoding (mp3, linear16, flac, mulaw, alaw, opus, aac)",
|
|
73
|
+
"type": str,
|
|
74
|
+
"is_option": True,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"names": ["--container"],
|
|
78
|
+
"help": "Audio container (none, wav, ogg)",
|
|
79
|
+
"type": str,
|
|
80
|
+
"is_option": True,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"names": ["--sample-rate"],
|
|
84
|
+
"help": "Audio sample rate in Hz",
|
|
85
|
+
"type": float,
|
|
86
|
+
"is_option": True,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"names": ["--file", "-f"],
|
|
90
|
+
"help": "Read text from file",
|
|
91
|
+
"type": str,
|
|
92
|
+
"is_option": True,
|
|
93
|
+
},
|
|
94
|
+
]
|
|
95
|
+
|
|
96
|
+
def handle(
|
|
97
|
+
self,
|
|
98
|
+
config: Config,
|
|
99
|
+
auth_manager: AuthManager,
|
|
100
|
+
client: DeepgramClient,
|
|
101
|
+
**kwargs: Any,
|
|
102
|
+
) -> BaseResult:
|
|
103
|
+
text = kwargs.get("text")
|
|
104
|
+
output_path = kwargs.get("output")
|
|
105
|
+
model = kwargs.get("model") or "aura-2-asteria-en"
|
|
106
|
+
encoding = kwargs.get("encoding")
|
|
107
|
+
container = kwargs.get("container")
|
|
108
|
+
sample_rate = kwargs.get("sample_rate")
|
|
109
|
+
file_path = kwargs.get("file")
|
|
110
|
+
|
|
111
|
+
# Resolve text input: arg > --file > stdin
|
|
112
|
+
if not text and file_path:
|
|
113
|
+
path = Path(file_path)
|
|
114
|
+
if not path.exists():
|
|
115
|
+
return BaseResult(
|
|
116
|
+
status="error", message=f"File not found: {file_path}"
|
|
117
|
+
)
|
|
118
|
+
text = path.read_text().strip()
|
|
119
|
+
elif not text and not sys.stdin.isatty():
|
|
120
|
+
text = sys.stdin.read().strip()
|
|
121
|
+
|
|
122
|
+
if not text:
|
|
123
|
+
return BaseResult(
|
|
124
|
+
status="error",
|
|
125
|
+
message="No text provided. Pass text as argument, use --file, or pipe via stdin.",
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
# If stdout is a TTY and no output file, require --output
|
|
129
|
+
stdout_is_tty = sys.stdout.isatty()
|
|
130
|
+
if not output_path and stdout_is_tty:
|
|
131
|
+
return BaseResult(
|
|
132
|
+
status="error",
|
|
133
|
+
message="No output specified. Use -o/--output to save to file, or pipe stdout.",
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
console.print(f"[blue]Generating speech with {model}...[/blue]")
|
|
138
|
+
|
|
139
|
+
audio_iter = client.speak_text(
|
|
140
|
+
text=text,
|
|
141
|
+
model=model,
|
|
142
|
+
encoding=encoding,
|
|
143
|
+
container=container,
|
|
144
|
+
sample_rate=sample_rate,
|
|
145
|
+
)
|
|
146
|
+
|
|
147
|
+
total_bytes = 0
|
|
148
|
+
|
|
149
|
+
if output_path:
|
|
150
|
+
# Write to file
|
|
151
|
+
out = Path(output_path)
|
|
152
|
+
with open(out, "wb") as f:
|
|
153
|
+
for chunk in audio_iter:
|
|
154
|
+
f.write(chunk)
|
|
155
|
+
total_bytes += len(chunk)
|
|
156
|
+
|
|
157
|
+
console.print(
|
|
158
|
+
f"[green]Audio saved to {output_path}[/green] ({total_bytes:,} bytes)"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
return SpeakResult(
|
|
162
|
+
status="success",
|
|
163
|
+
message=f"Audio saved to {output_path}",
|
|
164
|
+
output_path=output_path,
|
|
165
|
+
model=model,
|
|
166
|
+
bytes_written=total_bytes,
|
|
167
|
+
)
|
|
168
|
+
else:
|
|
169
|
+
# Write to stdout (piping)
|
|
170
|
+
stdout_buffer = sys.stdout.buffer
|
|
171
|
+
for chunk in audio_iter:
|
|
172
|
+
stdout_buffer.write(chunk)
|
|
173
|
+
total_bytes += len(chunk)
|
|
174
|
+
stdout_buffer.flush()
|
|
175
|
+
|
|
176
|
+
return SpeakResult(
|
|
177
|
+
status="success",
|
|
178
|
+
message=f"Wrote {total_bytes:,} bytes to stdout",
|
|
179
|
+
model=model,
|
|
180
|
+
bytes_written=total_bytes,
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
except Exception as e:
|
|
184
|
+
console.print(f"[red]Error generating speech:[/red] {e}")
|
|
185
|
+
return BaseResult(status="error", message=str(e))
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: deepctl-cmd-speak
|
|
3
|
+
Version: 0.0.2
|
|
4
|
+
Summary: Speak (text-to-speech) command for deepctl
|
|
5
|
+
Author-email: Deepgram <devrel@deepgram.com>
|
|
6
|
+
Maintainer-email: Deepgram <devrel@deepgram.com>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Keywords: deepgram,cli,tts,text-to-speech,speak
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: deepctl-core>=0.1.10
|
|
18
|
+
Requires-Dist: click>=8.0.0
|
|
19
|
+
Requires-Dist: rich>=13.0.0
|
|
20
|
+
Requires-Dist: pydantic>=2.0.0
|
|
21
|
+
|
|
22
|
+
# deepctl-cmd-speak
|
|
23
|
+
|
|
24
|
+
> Part of [deepctl](https://github.com/deepgram/cli) — Official Deepgram CLI
|
|
25
|
+
|
|
26
|
+
Speak (text-to-speech) command for deepctl
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
This package is included with deepctl and does not need to be installed separately.
|
|
31
|
+
|
|
32
|
+
### Install deepctl
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Install with pip
|
|
36
|
+
pip install deepctl
|
|
37
|
+
|
|
38
|
+
# Or install with uv
|
|
39
|
+
uv tool install deepctl
|
|
40
|
+
|
|
41
|
+
# Or install with pipx
|
|
42
|
+
pipx install deepctl
|
|
43
|
+
|
|
44
|
+
# Or run without installing
|
|
45
|
+
uvx deepctl --help
|
|
46
|
+
pipx run deepctl --help
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Commands
|
|
50
|
+
|
|
51
|
+
| Command | Entry Point |
|
|
52
|
+
|---------|-------------|
|
|
53
|
+
| `deepctl speak` | `deepctl_cmd_speak.command:SpeakCommand` |
|
|
54
|
+
|
|
55
|
+
## Dependencies
|
|
56
|
+
|
|
57
|
+
- `click>=8.0.0`
|
|
58
|
+
- `rich>=13.0.0`
|
|
59
|
+
- `pydantic>=2.0.0`
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT — see [LICENSE](../../LICENSE)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
README.md
|
|
2
|
+
pyproject.toml
|
|
3
|
+
src/deepctl_cmd_speak/__init__.py
|
|
4
|
+
src/deepctl_cmd_speak/command.py
|
|
5
|
+
src/deepctl_cmd_speak/models.py
|
|
6
|
+
src/deepctl_cmd_speak.egg-info/PKG-INFO
|
|
7
|
+
src/deepctl_cmd_speak.egg-info/SOURCES.txt
|
|
8
|
+
src/deepctl_cmd_speak.egg-info/dependency_links.txt
|
|
9
|
+
src/deepctl_cmd_speak.egg-info/entry_points.txt
|
|
10
|
+
src/deepctl_cmd_speak.egg-info/requires.txt
|
|
11
|
+
src/deepctl_cmd_speak.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
deepctl_cmd_speak
|