vox4ai-skill-lib 0.1.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.
- vox4ai_skill_lib-0.1.0/.gitignore +19 -0
- vox4ai_skill_lib-0.1.0/LICENSE +21 -0
- vox4ai_skill_lib-0.1.0/PKG-INFO +139 -0
- vox4ai_skill_lib-0.1.0/README.md +112 -0
- vox4ai_skill_lib-0.1.0/pyproject.toml +57 -0
- vox4ai_skill_lib-0.1.0/src/vox4ai_skill_lib/__init__.py +10 -0
- vox4ai_skill_lib-0.1.0/src/vox4ai_skill_lib/api.py +151 -0
- vox4ai_skill_lib-0.1.0/src/vox4ai_skill_lib/skill.py +322 -0
- vox4ai_skill_lib-0.1.0/tests/test_api.py +433 -0
- vox4ai_skill_lib-0.1.0/tests/test_skill.py +288 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 vox4ai
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: vox4ai-skill-lib
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: TTS skill for AI agents — synthesize, play, save speech via tts-plugin-bridge
|
|
5
|
+
Project-URL: Homepage, https://github.com/vox4ai/vox4ai-skill-lib
|
|
6
|
+
Project-URL: Repository, https://github.com/vox4ai/vox4ai-skill-lib
|
|
7
|
+
Project-URL: Issues, https://github.com/vox4ai/vox4ai-skill-lib/issues
|
|
8
|
+
Author-email: utenadev <utena.cross+pypi@gmail.com>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agent-skill,ai-agent,speech,synthesis,tts,tts-plugin,voice
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Multimedia :: Sound/Audio :: Speech
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Requires-Dist: aiohttp
|
|
25
|
+
Requires-Dist: tts-plugin-bridge
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# vox4ai-skill-lib
|
|
29
|
+
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="https://via.placeholder.com/1200x400/1a1a1a/ffffff?text=vox4ai-skill-lib" alt="vox4ai-skill-lib Banner" width="1200">
|
|
32
|
+
</p>
|
|
33
|
+
|
|
34
|
+
<p align="center">
|
|
35
|
+
<img src="https://img.shields.io/badge/pypi-latest-blue.svg" alt="PyPI version">
|
|
36
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
|
|
37
|
+
<img src="https://img.shields.io/badge/python-3.10%2B-yellow.svg" alt="Python Version">
|
|
38
|
+
<img src="https://img.shields.io/badge/maintained%3F-yes-brightgreen.svg" alt="Maintained">
|
|
39
|
+
</p>
|
|
40
|
+
|
|
41
|
+
<p align="center">
|
|
42
|
+
<a href="https://github.com/vox4ai/vox4ai-skill-lib">Website</a> •
|
|
43
|
+
<a href="https://github.com/vox4ai/vox4ai-skill-lib/issues">Report Bug</a> •
|
|
44
|
+
<a href="https://github.com/vox4ai/vox4ai-skill-lib/contributing">Contributing</a>
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
## 🚀 Overview
|
|
50
|
+
|
|
51
|
+
Python ライブラリとしての TTS Skill — AI agent や CLI から `tts-plugin-bridge` の TTS Engine を統一的に操作します。
|
|
52
|
+
|
|
53
|
+
## 📦 Installation
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
uv add vox4ai-skill-lib
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## 🛠 Usage
|
|
60
|
+
|
|
61
|
+
### 🧩 TTSSkill(推奨)
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import asyncio
|
|
65
|
+
from vox4ai_skill_lib import TTSSkill
|
|
66
|
+
|
|
67
|
+
async def main():
|
|
68
|
+
async with TTSSkill(default_engine="edgetts") as skill:
|
|
69
|
+
# 音声合成(Base64 で音声データ取得)
|
|
70
|
+
result = await skill.synthesize(text="こんにちは")
|
|
71
|
+
print(result["status"]) # "ok"
|
|
72
|
+
|
|
73
|
+
# ファイル保存
|
|
74
|
+
result = await skill.save(text="こんにちは")
|
|
75
|
+
|
|
76
|
+
# ストリーミング再生(ffplay 優先)
|
|
77
|
+
result = await skill.say(text="こんにちは")
|
|
78
|
+
|
|
79
|
+
# モデル指定
|
|
80
|
+
result = await skill.synthesize(
|
|
81
|
+
text="こんにちは",
|
|
82
|
+
model="ja-JP-KeitaNeural",
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
asyncio.run(main())
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### ⌨️ API 関数(簡易呼び出し用)
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
import asyncio
|
|
92
|
+
from vox4ai_skill_lib.api import list_engines, play_text
|
|
93
|
+
|
|
94
|
+
async def main():
|
|
95
|
+
await list_engines()
|
|
96
|
+
await play_text("こんにちは", engine="edgetts", speed=1.0,
|
|
97
|
+
volume=None, pitch=None, style_id=None,
|
|
98
|
+
model="ja-JP-NanamiNeural", engine_kwargs={})
|
|
99
|
+
|
|
100
|
+
asyncio.run(main())
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### 📑 TTSSkill API
|
|
104
|
+
|
|
105
|
+
| メソッド | 説明 |
|
|
106
|
+
|----------|------|
|
|
107
|
+
| `synthesize()` | 音声合成 → Base64 音声データを dict で返す |
|
|
108
|
+
| `save()` | `synthesize()` のエイリアス |
|
|
109
|
+
| `play()` | ストリーミング再生(ffplay)またはファイル再生(paplay/aplay) |
|
|
110
|
+
| `say()` | `play()` のエイリアス |
|
|
111
|
+
| `close()` | 全コネクタをクローズ |
|
|
112
|
+
|
|
113
|
+
全メソッドで `model` / `pitch` / `volume` / `style_id` / `engine` を **kwargs として受け付けます**。
|
|
114
|
+
|
|
115
|
+
コンテキストマネージャ対応:
|
|
116
|
+
|
|
117
|
+
```python
|
|
118
|
+
async with TTSSkill(default_engine="edgetts") as skill:
|
|
119
|
+
result = await skill.synthesize(text="test")
|
|
120
|
+
# close() 自動呼び出し
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### 📑 API 関数
|
|
124
|
+
|
|
125
|
+
| 関数 | 説明 |
|
|
126
|
+
|------|------|
|
|
127
|
+
| `list_engines()` | 利用可能な TTS Engine 一覧を表示 |
|
|
128
|
+
| `synthesize_text()` | 音声合成 + ファイル保存 / Base64 表示 |
|
|
129
|
+
| `play_text()` | テキスト読み上げ(ストリーミング + ファイルフォールバック) |
|
|
130
|
+
| `test_connection()` | TTS Engine への接続テスト |
|
|
131
|
+
|
|
132
|
+
## 📦 Dependencies
|
|
133
|
+
|
|
134
|
+
- `tts-plugin-bridge` — コアフレームワーク(protocol / factory / chunker)
|
|
135
|
+
- `aiohttp` — 非同期 HTTP
|
|
136
|
+
|
|
137
|
+
## 📜 License
|
|
138
|
+
|
|
139
|
+
MIT License
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# vox4ai-skill-lib
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="https://via.placeholder.com/1200x400/1a1a1a/ffffff?text=vox4ai-skill-lib" alt="vox4ai-skill-lib Banner" width="1200">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img src="https://img.shields.io/badge/pypi-latest-blue.svg" alt="PyPI version">
|
|
9
|
+
<img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License">
|
|
10
|
+
<img src="https://img.shields.io/badge/python-3.10%2B-yellow.svg" alt="Python Version">
|
|
11
|
+
<img src="https://img.shields.io/badge/maintained%3F-yes-brightgreen.svg" alt="Maintained">
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="https://github.com/vox4ai/vox4ai-skill-lib">Website</a> •
|
|
16
|
+
<a href="https://github.com/vox4ai/vox4ai-skill-lib/issues">Report Bug</a> •
|
|
17
|
+
<a href="https://github.com/vox4ai/vox4ai-skill-lib/contributing">Contributing</a>
|
|
18
|
+
</p>
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## 🚀 Overview
|
|
23
|
+
|
|
24
|
+
Python ライブラリとしての TTS Skill — AI agent や CLI から `tts-plugin-bridge` の TTS Engine を統一的に操作します。
|
|
25
|
+
|
|
26
|
+
## 📦 Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
uv add vox4ai-skill-lib
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🛠 Usage
|
|
33
|
+
|
|
34
|
+
### 🧩 TTSSkill(推奨)
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
import asyncio
|
|
38
|
+
from vox4ai_skill_lib import TTSSkill
|
|
39
|
+
|
|
40
|
+
async def main():
|
|
41
|
+
async with TTSSkill(default_engine="edgetts") as skill:
|
|
42
|
+
# 音声合成(Base64 で音声データ取得)
|
|
43
|
+
result = await skill.synthesize(text="こんにちは")
|
|
44
|
+
print(result["status"]) # "ok"
|
|
45
|
+
|
|
46
|
+
# ファイル保存
|
|
47
|
+
result = await skill.save(text="こんにちは")
|
|
48
|
+
|
|
49
|
+
# ストリーミング再生(ffplay 優先)
|
|
50
|
+
result = await skill.say(text="こんにちは")
|
|
51
|
+
|
|
52
|
+
# モデル指定
|
|
53
|
+
result = await skill.synthesize(
|
|
54
|
+
text="こんにちは",
|
|
55
|
+
model="ja-JP-KeitaNeural",
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
asyncio.run(main())
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### ⌨️ API 関数(簡易呼び出し用)
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import asyncio
|
|
65
|
+
from vox4ai_skill_lib.api import list_engines, play_text
|
|
66
|
+
|
|
67
|
+
async def main():
|
|
68
|
+
await list_engines()
|
|
69
|
+
await play_text("こんにちは", engine="edgetts", speed=1.0,
|
|
70
|
+
volume=None, pitch=None, style_id=None,
|
|
71
|
+
model="ja-JP-NanamiNeural", engine_kwargs={})
|
|
72
|
+
|
|
73
|
+
asyncio.run(main())
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 📑 TTSSkill API
|
|
77
|
+
|
|
78
|
+
| メソッド | 説明 |
|
|
79
|
+
|----------|------|
|
|
80
|
+
| `synthesize()` | 音声合成 → Base64 音声データを dict で返す |
|
|
81
|
+
| `save()` | `synthesize()` のエイリアス |
|
|
82
|
+
| `play()` | ストリーミング再生(ffplay)またはファイル再生(paplay/aplay) |
|
|
83
|
+
| `say()` | `play()` のエイリアス |
|
|
84
|
+
| `close()` | 全コネクタをクローズ |
|
|
85
|
+
|
|
86
|
+
全メソッドで `model` / `pitch` / `volume` / `style_id` / `engine` を **kwargs として受け付けます**。
|
|
87
|
+
|
|
88
|
+
コンテキストマネージャ対応:
|
|
89
|
+
|
|
90
|
+
```python
|
|
91
|
+
async with TTSSkill(default_engine="edgetts") as skill:
|
|
92
|
+
result = await skill.synthesize(text="test")
|
|
93
|
+
# close() 自動呼び出し
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### 📑 API 関数
|
|
97
|
+
|
|
98
|
+
| 関数 | 説明 |
|
|
99
|
+
|------|------|
|
|
100
|
+
| `list_engines()` | 利用可能な TTS Engine 一覧を表示 |
|
|
101
|
+
| `synthesize_text()` | 音声合成 + ファイル保存 / Base64 表示 |
|
|
102
|
+
| `play_text()` | テキスト読み上げ(ストリーミング + ファイルフォールバック) |
|
|
103
|
+
| `test_connection()` | TTS Engine への接続テスト |
|
|
104
|
+
|
|
105
|
+
## 📦 Dependencies
|
|
106
|
+
|
|
107
|
+
- `tts-plugin-bridge` — コアフレームワーク(protocol / factory / chunker)
|
|
108
|
+
- `aiohttp` — 非同期 HTTP
|
|
109
|
+
|
|
110
|
+
## 📜 License
|
|
111
|
+
|
|
112
|
+
MIT License
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "vox4ai-skill-lib"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "TTS skill for AI agents — synthesize, play, save speech via tts-plugin-bridge"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"tts-plugin-bridge",
|
|
13
|
+
"aiohttp",
|
|
14
|
+
]
|
|
15
|
+
license = {text = "MIT"}
|
|
16
|
+
authors = [
|
|
17
|
+
{name = "utenadev", email = "utena.cross+pypi@gmail.com"},
|
|
18
|
+
]
|
|
19
|
+
keywords = ["tts", "tts-plugin", "voice", "speech", "synthesis", "agent-skill", "ai-agent"]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Development Status :: 4 - Beta",
|
|
22
|
+
"Intended Audience :: Developers",
|
|
23
|
+
"License :: OSI Approved :: MIT License",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
"Programming Language :: Python :: 3",
|
|
26
|
+
"Programming Language :: Python :: 3.10",
|
|
27
|
+
"Programming Language :: Python :: 3.11",
|
|
28
|
+
"Programming Language :: Python :: 3.12",
|
|
29
|
+
"Programming Language :: Python :: 3.13",
|
|
30
|
+
"Topic :: Multimedia :: Sound/Audio :: Speech",
|
|
31
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.urls]
|
|
35
|
+
Homepage = "https://github.com/vox4ai/vox4ai-skill-lib"
|
|
36
|
+
Repository = "https://github.com/vox4ai/vox4ai-skill-lib"
|
|
37
|
+
Issues = "https://github.com/vox4ai/vox4ai-skill-lib/issues"
|
|
38
|
+
|
|
39
|
+
[tool.uv.sources]
|
|
40
|
+
tts-plugin-bridge = { path = "../tts-plugin-bridge", editable = true }
|
|
41
|
+
|
|
42
|
+
[dependency-groups]
|
|
43
|
+
dev = [
|
|
44
|
+
"pytest-cov>=6.0.0",
|
|
45
|
+
"pytest>=9.0.3",
|
|
46
|
+
"pytest-asyncio>=1.3.0",
|
|
47
|
+
"ruff>=0.15.12",
|
|
48
|
+
"build>=1.0",
|
|
49
|
+
"twine>=6.0",
|
|
50
|
+
]
|
|
51
|
+
|
|
52
|
+
[tool.ruff]
|
|
53
|
+
target-version = "py310"
|
|
54
|
+
|
|
55
|
+
[tool.pytest.ini_options]
|
|
56
|
+
asyncio_mode = "strict"
|
|
57
|
+
testpaths = ["tests"]
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
|
|
3
|
+
from tts_plugin_bridge import ConnectorFactory
|
|
4
|
+
from tts_plugin_bridge.protocol import ChunkConfig
|
|
5
|
+
|
|
6
|
+
from .skill import TTSSkill, _play_audio
|
|
7
|
+
from typing import Optional
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async def list_engines():
|
|
11
|
+
try:
|
|
12
|
+
engines = ConnectorFactory.list_available()
|
|
13
|
+
if engines:
|
|
14
|
+
print("利用可能なTTSプラグイン:")
|
|
15
|
+
for engine in engines:
|
|
16
|
+
print(f" - {engine}")
|
|
17
|
+
else:
|
|
18
|
+
print("利用可能なTTSプラグインが見つかりません。")
|
|
19
|
+
print("プラグインをインストールするには: uv add tts-plugin-<エンジン名>")
|
|
20
|
+
except Exception as e:
|
|
21
|
+
print(f"エラー: {e}")
|
|
22
|
+
return 1
|
|
23
|
+
return 0
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
async def synthesize_text(
|
|
27
|
+
text: str,
|
|
28
|
+
engine: Optional[str],
|
|
29
|
+
speed: float,
|
|
30
|
+
volume: Optional[float],
|
|
31
|
+
pitch: Optional[float],
|
|
32
|
+
style_id: Optional[int],
|
|
33
|
+
output: Optional[str],
|
|
34
|
+
engine_kwargs: dict,
|
|
35
|
+
chunk: bool = False,
|
|
36
|
+
play: bool = False,
|
|
37
|
+
chunk_config: Optional[ChunkConfig] = None,
|
|
38
|
+
):
|
|
39
|
+
try:
|
|
40
|
+
async with TTSSkill(
|
|
41
|
+
default_engine=engine or "piperplus", **engine_kwargs
|
|
42
|
+
) as skill:
|
|
43
|
+
kwargs: dict = {}
|
|
44
|
+
if volume is not None:
|
|
45
|
+
kwargs["volume"] = volume
|
|
46
|
+
if pitch is not None:
|
|
47
|
+
kwargs["pitch"] = pitch
|
|
48
|
+
if style_id is not None:
|
|
49
|
+
kwargs["style_id"] = style_id
|
|
50
|
+
if chunk:
|
|
51
|
+
kwargs["chunk"] = True
|
|
52
|
+
kwargs["chunk_config"] = chunk_config
|
|
53
|
+
|
|
54
|
+
result = await skill.synthesize(
|
|
55
|
+
text=text, speed=speed, engine=engine, **kwargs
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if result.ok:
|
|
59
|
+
audio_data = base64.b64decode(result.audio_base64 or "")
|
|
60
|
+
if output:
|
|
61
|
+
with open(output, "wb") as f:
|
|
62
|
+
f.write(audio_data)
|
|
63
|
+
print(f"音声データを {output} に保存しました。")
|
|
64
|
+
print(f"エンジン: {result.engine}")
|
|
65
|
+
print(f"メッセージ: {result.message}")
|
|
66
|
+
elif play:
|
|
67
|
+
ok = await _play_audio(audio_data)
|
|
68
|
+
if not ok:
|
|
69
|
+
print(
|
|
70
|
+
"エラー: 再生に使えるコマンド (paplay / aplay) が見つかりません。"
|
|
71
|
+
)
|
|
72
|
+
return 1
|
|
73
|
+
print(f"✅ 再生完了 (エンジン: {result.engine})")
|
|
74
|
+
else:
|
|
75
|
+
print(f"エンジン: {result.engine}")
|
|
76
|
+
print(f"メッセージ: {result.message}")
|
|
77
|
+
if result.audio_base64:
|
|
78
|
+
print(f"音声データ (Base64): {result.audio_base64[:100]}...")
|
|
79
|
+
if len(result.audio_base64) > 100:
|
|
80
|
+
print(f"... (全長: {len(result.audio_base64)} 文字)")
|
|
81
|
+
else:
|
|
82
|
+
print("音声データ: None")
|
|
83
|
+
else:
|
|
84
|
+
print(f"エラー: {result.message}")
|
|
85
|
+
return 1
|
|
86
|
+
except Exception as e:
|
|
87
|
+
print(f"エラー: {e}")
|
|
88
|
+
return 1
|
|
89
|
+
return 0
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
async def play_text(
|
|
93
|
+
text: str,
|
|
94
|
+
engine: Optional[str],
|
|
95
|
+
speed: float,
|
|
96
|
+
volume: Optional[float],
|
|
97
|
+
pitch: Optional[float],
|
|
98
|
+
style_id: Optional[int],
|
|
99
|
+
model: Optional[str],
|
|
100
|
+
engine_kwargs: dict,
|
|
101
|
+
):
|
|
102
|
+
try:
|
|
103
|
+
async with TTSSkill(
|
|
104
|
+
default_engine=engine or "piperplus", **engine_kwargs
|
|
105
|
+
) as skill:
|
|
106
|
+
kwargs: dict = {}
|
|
107
|
+
if volume is not None:
|
|
108
|
+
kwargs["volume"] = volume
|
|
109
|
+
if pitch is not None:
|
|
110
|
+
kwargs["pitch"] = pitch
|
|
111
|
+
if style_id is not None:
|
|
112
|
+
kwargs["style_id"] = style_id
|
|
113
|
+
if model is not None:
|
|
114
|
+
kwargs["model"] = model
|
|
115
|
+
result = await skill.play(text=text, speed=speed, engine=engine, **kwargs)
|
|
116
|
+
if result.ok:
|
|
117
|
+
print(f"✅ {result.message} (エンジン: {result.engine})")
|
|
118
|
+
else:
|
|
119
|
+
print(f"エラー: {result.message}")
|
|
120
|
+
return 1
|
|
121
|
+
except Exception as e:
|
|
122
|
+
print(f"エラー: {e}")
|
|
123
|
+
return 1
|
|
124
|
+
return 0
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
async def test_connection(
|
|
128
|
+
engine: Optional[str], style_id: Optional[int], engine_kwargs: dict
|
|
129
|
+
):
|
|
130
|
+
try:
|
|
131
|
+
async with TTSSkill(
|
|
132
|
+
default_engine=engine or "piperplus", **engine_kwargs
|
|
133
|
+
) as skill:
|
|
134
|
+
kwargs: dict = {}
|
|
135
|
+
if style_id is not None:
|
|
136
|
+
kwargs["style_id"] = style_id
|
|
137
|
+
result = await skill.synthesize(
|
|
138
|
+
text="テスト", speed=1.0, engine=engine, **kwargs
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
if result.ok:
|
|
142
|
+
print("✅ 接続成功!")
|
|
143
|
+
print(f"エンジン: {result.engine}")
|
|
144
|
+
print(f"メッセージ: {result.message}")
|
|
145
|
+
else:
|
|
146
|
+
print(f"❌ 接続失敗: {result.message}")
|
|
147
|
+
return 1
|
|
148
|
+
except Exception as e:
|
|
149
|
+
print(f"❌ エラー: {e}")
|
|
150
|
+
return 1
|
|
151
|
+
return 0
|