vocal-cli 0.3.0__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.
- vocal_cli-0.3.0/.gitignore +74 -0
- vocal_cli-0.3.0/MANIFEST.in +3 -0
- vocal_cli-0.3.0/PKG-INFO +24 -0
- vocal_cli-0.3.0/pyproject.toml +39 -0
- vocal_cli-0.3.0/vocal_cli/__init__.py +7 -0
- vocal_cli-0.3.0/vocal_cli/main.py +208 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.Python
|
|
7
|
+
build/
|
|
8
|
+
develop-eggs/
|
|
9
|
+
dist/
|
|
10
|
+
downloads/
|
|
11
|
+
eggs/
|
|
12
|
+
.eggs/
|
|
13
|
+
lib/
|
|
14
|
+
lib64/
|
|
15
|
+
parts/
|
|
16
|
+
sdist/
|
|
17
|
+
var/
|
|
18
|
+
wheels/
|
|
19
|
+
*.egg-info/
|
|
20
|
+
.installed.cfg
|
|
21
|
+
*.egg
|
|
22
|
+
MANIFEST
|
|
23
|
+
|
|
24
|
+
# Virtual Environment
|
|
25
|
+
.venv/
|
|
26
|
+
venv/
|
|
27
|
+
ENV/
|
|
28
|
+
env/
|
|
29
|
+
|
|
30
|
+
# UV
|
|
31
|
+
uv.lock
|
|
32
|
+
|
|
33
|
+
# IDE
|
|
34
|
+
.vscode/
|
|
35
|
+
.idea/
|
|
36
|
+
*.swp
|
|
37
|
+
*.swo
|
|
38
|
+
*~
|
|
39
|
+
.DS_Store
|
|
40
|
+
|
|
41
|
+
# Testing
|
|
42
|
+
.pytest_cache/
|
|
43
|
+
.coverage
|
|
44
|
+
htmlcov/
|
|
45
|
+
.tox/
|
|
46
|
+
|
|
47
|
+
# Jupyter
|
|
48
|
+
.ipynb_checkpoints
|
|
49
|
+
|
|
50
|
+
# Model cache
|
|
51
|
+
.cache/
|
|
52
|
+
models/
|
|
53
|
+
*.ckpt
|
|
54
|
+
*.pth
|
|
55
|
+
*.pt
|
|
56
|
+
*.safetensors
|
|
57
|
+
|
|
58
|
+
# Audio files (test data)
|
|
59
|
+
*.mp3
|
|
60
|
+
*.wav
|
|
61
|
+
*.m4a
|
|
62
|
+
*.ogg
|
|
63
|
+
*.flac
|
|
64
|
+
|
|
65
|
+
# Logs
|
|
66
|
+
*.log
|
|
67
|
+
logs/
|
|
68
|
+
|
|
69
|
+
# Environment variables
|
|
70
|
+
.env
|
|
71
|
+
.env.local
|
|
72
|
+
|
|
73
|
+
# OS
|
|
74
|
+
Thumbs.db
|
vocal_cli-0.3.0/PKG-INFO
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vocal-cli
|
|
3
|
+
Version: 0.3.0
|
|
4
|
+
Summary: CLI tool for Vocal - Ollama-style Voice Model Management
|
|
5
|
+
Project-URL: Homepage, https://github.com/niradler/vocal
|
|
6
|
+
Project-URL: Documentation, https://github.com/niradler/vocal#readme
|
|
7
|
+
Project-URL: Repository, https://github.com/niradler/vocal
|
|
8
|
+
Project-URL: Issues, https://github.com/niradler/vocal/issues
|
|
9
|
+
Author: Vocal Contributors
|
|
10
|
+
License: SSPL-1.0
|
|
11
|
+
Keywords: cli,command-line,ollama,speech-to-text,tts,voice
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Environment :: Console
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: Other/Proprietary License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Utilities
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: rich>=13.0.0
|
|
22
|
+
Requires-Dist: typer>=0.12.0
|
|
23
|
+
Requires-Dist: uvicorn>=0.31.0
|
|
24
|
+
Requires-Dist: vocal-sdk>=0.3.0
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "vocal-cli"
|
|
3
|
+
version = "0.3.0"
|
|
4
|
+
description = "CLI tool for Vocal - Ollama-style Voice Model Management"
|
|
5
|
+
requires-python = ">=3.11"
|
|
6
|
+
license = { text = "SSPL-1.0" }
|
|
7
|
+
authors = [
|
|
8
|
+
{ name = "Vocal Contributors" }
|
|
9
|
+
]
|
|
10
|
+
keywords = ["cli", "command-line", "speech-to-text", "tts", "ollama", "voice"]
|
|
11
|
+
classifiers = [
|
|
12
|
+
"Development Status :: 3 - Alpha",
|
|
13
|
+
"Intended Audience :: Developers",
|
|
14
|
+
"License :: Other/Proprietary License",
|
|
15
|
+
"Programming Language :: Python :: 3.11",
|
|
16
|
+
"Programming Language :: Python :: 3.12",
|
|
17
|
+
"Programming Language :: Python :: 3.13",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Topic :: Utilities",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"vocal-sdk>=0.3.0",
|
|
23
|
+
"typer>=0.12.0",
|
|
24
|
+
"rich>=13.0.0",
|
|
25
|
+
"uvicorn>=0.31.0",
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
[project.urls]
|
|
29
|
+
Homepage = "https://github.com/niradler/vocal"
|
|
30
|
+
Documentation = "https://github.com/niradler/vocal#readme"
|
|
31
|
+
Repository = "https://github.com/niradler/vocal"
|
|
32
|
+
Issues = "https://github.com/niradler/vocal/issues"
|
|
33
|
+
|
|
34
|
+
[project.scripts]
|
|
35
|
+
vocal = "vocal_cli.main:app"
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["hatchling"]
|
|
39
|
+
build-backend = "hatchling.build"
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
from pathlib import Path
|
|
2
|
+
|
|
3
|
+
import typer
|
|
4
|
+
from rich.console import Console
|
|
5
|
+
from rich.table import Table
|
|
6
|
+
|
|
7
|
+
from vocal_sdk import VocalSDK
|
|
8
|
+
|
|
9
|
+
app = typer.Typer(
|
|
10
|
+
name="vocal",
|
|
11
|
+
help="Vocal - Generic Speech AI Platform CLI",
|
|
12
|
+
no_args_is_help=True,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
models_app = typer.Typer(help="Model management commands")
|
|
16
|
+
app.add_typer(models_app, name="models")
|
|
17
|
+
|
|
18
|
+
console = Console()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@app.command()
|
|
22
|
+
def run(
|
|
23
|
+
audio_file: Path = typer.Argument(..., help="Path to audio file to transcribe"),
|
|
24
|
+
model: str = typer.Option(
|
|
25
|
+
"Systran/faster-whisper-tiny",
|
|
26
|
+
"--model",
|
|
27
|
+
"-m",
|
|
28
|
+
help="Model to use for transcription",
|
|
29
|
+
),
|
|
30
|
+
language: str | None = typer.Option(None, "--language", "-l", help="Language code (e.g., 'en', 'es')"),
|
|
31
|
+
output_format: str = typer.Option("text", "--format", "-f", help="Output format: text, json, srt, vtt"),
|
|
32
|
+
api_url: str = typer.Option("http://localhost:8000", "--api-url", help="Vocal API URL"),
|
|
33
|
+
):
|
|
34
|
+
"""Transcribe audio file to text"""
|
|
35
|
+
if not audio_file.exists():
|
|
36
|
+
console.print(f"[red]Error:[/red] File not found: {audio_file}")
|
|
37
|
+
raise typer.Exit(1)
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
client = VocalSDK(base_url=api_url)
|
|
41
|
+
|
|
42
|
+
console.print("Transcribing audio...")
|
|
43
|
+
|
|
44
|
+
result = client.audio.transcribe(
|
|
45
|
+
file=str(audio_file),
|
|
46
|
+
model=model,
|
|
47
|
+
language=language,
|
|
48
|
+
response_format="json",
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
if output_format == "text":
|
|
52
|
+
console.print(result["text"])
|
|
53
|
+
elif output_format == "json":
|
|
54
|
+
import json
|
|
55
|
+
|
|
56
|
+
console.print_json(json.dumps(result))
|
|
57
|
+
elif output_format == "srt":
|
|
58
|
+
for seg in result.get("segments", []):
|
|
59
|
+
console.print(f"{seg['id'] + 1}")
|
|
60
|
+
start = _format_timestamp(seg["start"])
|
|
61
|
+
end = _format_timestamp(seg["end"])
|
|
62
|
+
console.print(f"{start} --> {end}")
|
|
63
|
+
console.print(seg["text"])
|
|
64
|
+
console.print()
|
|
65
|
+
elif output_format == "vtt":
|
|
66
|
+
console.print("WEBVTT\n")
|
|
67
|
+
for seg in result.get("segments", []):
|
|
68
|
+
start = _format_timestamp(seg["start"], use_comma=False)
|
|
69
|
+
end = _format_timestamp(seg["end"], use_comma=False)
|
|
70
|
+
console.print(f"{start} --> {end}")
|
|
71
|
+
console.print(seg["text"])
|
|
72
|
+
console.print()
|
|
73
|
+
|
|
74
|
+
except Exception as e:
|
|
75
|
+
console.print(f"[red]Error:[/red] {str(e)}")
|
|
76
|
+
raise typer.Exit(1)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@models_app.command("list")
|
|
80
|
+
def models_list(
|
|
81
|
+
status: str | None = typer.Option(
|
|
82
|
+
None,
|
|
83
|
+
"--status",
|
|
84
|
+
"-s",
|
|
85
|
+
help="Filter by status: available, downloading, not_downloaded",
|
|
86
|
+
),
|
|
87
|
+
task: str | None = typer.Option(None, "--task", "-t", help="Filter by task: stt, tts"),
|
|
88
|
+
api_url: str = typer.Option("http://localhost:8000", "--api-url", help="Vocal API URL"),
|
|
89
|
+
):
|
|
90
|
+
"""List all available models"""
|
|
91
|
+
try:
|
|
92
|
+
client = VocalSDK(base_url=api_url)
|
|
93
|
+
response = client.models.list(status=status, task=task)
|
|
94
|
+
|
|
95
|
+
table = Table(title="Vocal Models")
|
|
96
|
+
table.add_column("Model ID", style="cyan")
|
|
97
|
+
table.add_column("Task", style="magenta")
|
|
98
|
+
table.add_column("Status", style="green")
|
|
99
|
+
table.add_column("Size", style="yellow")
|
|
100
|
+
|
|
101
|
+
for model in response["models"]:
|
|
102
|
+
status_color = {
|
|
103
|
+
"available": "green",
|
|
104
|
+
"downloading": "yellow",
|
|
105
|
+
"not_downloaded": "red",
|
|
106
|
+
}.get(model["status"], "white")
|
|
107
|
+
|
|
108
|
+
table.add_row(
|
|
109
|
+
model["id"],
|
|
110
|
+
model.get("task", "N/A"),
|
|
111
|
+
f"[{status_color}]{model['status']}[/{status_color}]",
|
|
112
|
+
str(model.get("size", "N/A")),
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
console.print(table)
|
|
116
|
+
console.print(f"\nTotal models: {response['total']}")
|
|
117
|
+
|
|
118
|
+
except Exception as e:
|
|
119
|
+
console.print(f"[red]Error:[/red] {str(e)}")
|
|
120
|
+
raise typer.Exit(1)
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
@models_app.command("pull")
|
|
124
|
+
def models_pull(
|
|
125
|
+
model_id: str = typer.Argument(..., help="Model ID to download"),
|
|
126
|
+
api_url: str = typer.Option("http://localhost:8000", "--api-url", help="Vocal API URL"),
|
|
127
|
+
):
|
|
128
|
+
"""Download a model (Ollama-style pull)"""
|
|
129
|
+
try:
|
|
130
|
+
client = VocalSDK(base_url=api_url)
|
|
131
|
+
|
|
132
|
+
console.print(f"Downloading {model_id}...")
|
|
133
|
+
|
|
134
|
+
result = client.models.download(model_id)
|
|
135
|
+
|
|
136
|
+
console.print(f"[green]Successfully downloaded:[/green] {model_id}")
|
|
137
|
+
console.print(f"Status: {result.get('status', 'unknown')}")
|
|
138
|
+
|
|
139
|
+
except Exception as e:
|
|
140
|
+
console.print(f"[red]Error:[/red] {str(e)}")
|
|
141
|
+
raise typer.Exit(1)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
@models_app.command("delete")
|
|
145
|
+
def models_delete(
|
|
146
|
+
model_id: str = typer.Argument(..., help="Model ID to delete"),
|
|
147
|
+
api_url: str = typer.Option("http://localhost:8000", "--api-url", help="Vocal API URL"),
|
|
148
|
+
force: bool = typer.Option(False, "--force", "-f", help="Skip confirmation prompt"),
|
|
149
|
+
):
|
|
150
|
+
"""Delete a downloaded model"""
|
|
151
|
+
if not force:
|
|
152
|
+
confirm = typer.confirm(f"Are you sure you want to delete {model_id}?")
|
|
153
|
+
if not confirm:
|
|
154
|
+
console.print("Cancelled")
|
|
155
|
+
raise typer.Exit(0)
|
|
156
|
+
|
|
157
|
+
try:
|
|
158
|
+
client = VocalSDK(base_url=api_url)
|
|
159
|
+
client.models.delete(model_id)
|
|
160
|
+
|
|
161
|
+
console.print(f"[green]Successfully deleted:[/green] {model_id}")
|
|
162
|
+
|
|
163
|
+
except Exception as e:
|
|
164
|
+
console.print(f"[red]Error:[/red] {str(e)}")
|
|
165
|
+
raise typer.Exit(1)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@app.command()
|
|
169
|
+
def serve(
|
|
170
|
+
host: str = typer.Option("0.0.0.0", "--host", "-h", help="Host to bind to"),
|
|
171
|
+
port: int = typer.Option(8000, "--port", "-p", help="Port to bind to"),
|
|
172
|
+
reload: bool = typer.Option(False, "--reload", help="Enable auto-reload"),
|
|
173
|
+
):
|
|
174
|
+
"""Start the Vocal API server"""
|
|
175
|
+
import uvicorn
|
|
176
|
+
|
|
177
|
+
console.print("[green]Starting Vocal API server...[/green]")
|
|
178
|
+
console.print(f"API: http://{host}:{port}")
|
|
179
|
+
console.print(f"Docs: http://{host}:{port}/docs")
|
|
180
|
+
|
|
181
|
+
try:
|
|
182
|
+
uvicorn.run(
|
|
183
|
+
"vocal_api.main:app",
|
|
184
|
+
host=host,
|
|
185
|
+
port=port,
|
|
186
|
+
reload=reload,
|
|
187
|
+
)
|
|
188
|
+
except KeyboardInterrupt:
|
|
189
|
+
console.print("\n[yellow]Server stopped[/yellow]")
|
|
190
|
+
except Exception as e:
|
|
191
|
+
console.print(f"[red]Error:[/red] {str(e)}")
|
|
192
|
+
raise typer.Exit(1)
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def _format_timestamp(seconds: float, use_comma: bool = True) -> str:
|
|
196
|
+
"""Format timestamp for SRT/VTT output"""
|
|
197
|
+
hours = int(seconds // 3600)
|
|
198
|
+
minutes = int((seconds % 3600) // 60)
|
|
199
|
+
secs = seconds % 60
|
|
200
|
+
|
|
201
|
+
if use_comma:
|
|
202
|
+
return f"{hours:02d}:{minutes:02d}:{secs:06.3f}".replace(".", ",")
|
|
203
|
+
else:
|
|
204
|
+
return f"{hours:02d}:{minutes:02d}:{secs:06.3f}"
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
if __name__ == "__main__":
|
|
208
|
+
app()
|